diff --git a/README.md b/README.md index 10287ca..e9da4d8 100644 --- a/README.md +++ b/README.md @@ -1,83 +1,38 @@ # Project #1 - Library Project using Dart +## About Project 1: -Congratulations on reaching the project phase! This project will assess your ability to develop a "Library Project using Dart" with a Command Line Interface (CLI) to manage a library's book inventory and user interactions. Below are the key requirements and evaluation criteria: +### Library System is a application using Dart with a Command Line Interface (CLI) . +## Functions: +- Display All Books . +- Add books . +- Delete Book. +- Search books by ID. +- Buy a book . -## Description: - -The "Library Project using Dart" is an exciting software application designed to efficiently manage a library's book inventory and streamline user interactions through a Command Line Interface (CLI). This capstone project provides you, as a student, with an excellent opportunity to apply your knowledge and skills in Flutter Development, showcasing your proficiency in Dart programming. - -The primary goal of the project is to develop a user-friendly and efficient CLI that caters to both library staff and patrons. With this CLI, users can effortlessly query books, view the number of available copies, add new books to the library, delete books from the inventory, make book purchases, and receive detailed invoices after each purchase. Additionally, the project demands an essential feature - updating the number of book copies after a purchase is made to maintain accurate inventory records. - -To begin, you will create a new Dart project, ensuring that the project structure is appropriately organized for a clean and manageable codebase. As you progress, it is crucial to write code that is clear, well-organized, and scalable, adhering to standard coding conventions to enhance code readability. Demonstrating your comprehensive understanding of programming concepts and techniques is essential for a successful outcome. - -Your CLI should allow users to search for books by title, author, or category, providing a straightforward and accessible way to retrieve information about the library's collection. Implementing a method to add new books to the library with the appropriate updates to the book count will further enhance the system's usability. - -Managing the library's inventory also involves implementing a method to delete books, ensuring smooth handling of cases where a book to be deleted does not exist. Facilitating book purchases through the CLI is another critical aspect, requiring you to decrease the number of book copies according to the books purchased and generate an informative invoice for the user. - -As an extra credit opportunity, you can implement features such as displaying all book categories in the library, returning a list of books belonging to a selected category. Additionally, providing a method to count the number of purchased books will further showcase your skills. - -The project must be written entirely in the Dart language and fully submitted through GitHub using version control (Git). Remember to create descriptive commits to showcase your progress and follow the provided guidelines for academic integrity. - - - -## Minimum Requirements: - -1. **Project Structure**: Create a new Dart project and organize its structure appropriately. Set up the necessary folders, files, and ensure a clean and organized project layout. - -2. **Clean Code**: Write clear, well-organized, and scalable code. Use meaningful variable and function names, following standard coding conventions to improve code readability. Well-structured and easily maintainable code is essential. - -3. **Applying Concepts**: Demonstrate a comprehensive understanding of programming concepts and techniques. Implement the CLI features with efficiency and correctness. - -4. **Query Books**: Develop a simple CLI user interface that allows users to query books and view the number of available copies. Users should be able to search for books by title, author, or category. - -5. **Add New Book**: Provide a method to add a new book to the library and update the number of book copies accordingly. Ensure proper error handling for invalid inputs. - -6. **Delete Book**: Implement a method to delete a book from the library and update the book count. Handle cases where the book to be deleted does not exist. - -7. **Purchase**: Implement the purchase process, allowing users to buy books from the library. Ensure that the number of book copies is decreased according to the books purchased. - -8. **Invoice**: Display a detailed invoice after the purchase, showing the books purchased, their prices, and the total cost. - -9. **Editing Capability**: Add the ability to modify book data, such as title, author, and price. Users should be able to update book information easily. - -## Ideas for Extra Credit: - -- **Display all Book Categories**: Provide a method to display a list of all book categories in the library. When a category is selected, return a list of all books belonging to that category. -- **Reporting:** Provide a method to present a report that contains the number of all purchased books from the library, and calculate their amount. + ----------- + #### We have a data of books stored in a file MyBooks.dart : +![Screenshot 2023-07-30 200313](https://github.com/AbrarSaud/Project-dart-1/assets/109272922/feb329e8-f938-486e-be6a-4b7328a12250) -## Delivery Requirements: - -- **Language**: The project should be written in Dart language. - -- **GitHub Submission**: - - Create a Fork from the exam’s GitHub repository. - - Create a new branch with your name, i.e., Nawaf-Alshawan. - - Commit frequently with descriptive messages to show your progress. - - Finally, create a Pull Request to the exam’s original repository containing your solution. - -- **README.md File**: Include a README.md file with instructions on how to run and test the project. This file should provide a clear guide for users to understand how to interact with the CLI. - -- **Screenshots**: Include relevant screenshots of the app to showcase its appearance and functionalities. Visuals can help users understand the app's design and layout. - -## Schedule & Deadlines: - -- Exam Start Date: 27/7/2023 - 3:00 PM -- Exam Submission Deadline: 30/7/2023 – 11:59 PM - -## Evaluation Criteria: - -The project will be evaluated based on the following criteria: +#### Output: +#### Menu for Library Management : +![menu](https://github.com/AbrarSaud/Project-dart-1/assets/109272922/633bb15e-b997-4c83-a37f-8620998fc94c) -- **Completion**: The extent to which the project meets all the minimum requirements, including the extra credit ideas if implemented. +### 1) Show All Book : +![Display All Books](https://github.com/AbrarSaud/Project-dart-1/assets/109272922/d5c16675-da4b-4d09-8af2-85251a8f1e00) -- **Quality**: The overall quality of the project, including the coding style, organization, and ease of maintenance. Well-structured and readable code will be favorably evaluated. +### 2) Add Book : +![Add Book](https://github.com/AbrarSaud/Project-dart-1/assets/109272922/0cdca57e-a1fa-4518-8597-641bfb905175) -- **Use of Programming Concepts**: How well you utilize programming concepts such as classes, abstracts, functions, and other relevant techniques. +- after adding : + ![Display data of add book](https://github.com/AbrarSaud/Project-dart-1/assets/109272922/4aecf317-75be-44fe-8731-0d571ce66125) -## Resources +### 3) Delete Book : +![delete Book By Ib](https://github.com/AbrarSaud/Project-dart-1/assets/109272922/43b2cc38-8925-4d76-b61f-771020839aa7) -- [Dart Tutorials](https://dart.dev/tutorials) +### 4 ) Search Book by Id: +![Search Book by Id](https://github.com/AbrarSaud/Project-dart-1/assets/109272922/9dd95aa0-9640-4f64-8024-fbdd0f075ebd) -Good luck with the project, and feel free to ask any additional questions if needed! +### 5) Buy a book : +![Buy a book](https://github.com/AbrarSaud/Project-dart-1/assets/109272922/f773907e-5269-4481-abcd-29ee12780391) diff --git a/project1/.gitignore b/project1/.gitignore new file mode 100644 index 0000000..3a85790 --- /dev/null +++ b/project1/.gitignore @@ -0,0 +1,3 @@ +# https://dart.dev/guides/libraries/private-files +# Created by `dart pub` +.dart_tool/ diff --git a/project1/CHANGELOG.md b/project1/CHANGELOG.md new file mode 100644 index 0000000..effe43c --- /dev/null +++ b/project1/CHANGELOG.md @@ -0,0 +1,3 @@ +## 1.0.0 + +- Initial version. diff --git a/project1/README.md b/project1/README.md new file mode 100644 index 0000000..3816eca --- /dev/null +++ b/project1/README.md @@ -0,0 +1,2 @@ +A sample command-line application with an entrypoint in `bin/`, library code +in `lib/`, and example unit test in `test/`. diff --git a/project1/access/Add Book.png b/project1/access/Add Book.png new file mode 100644 index 0000000..9d3730d Binary files /dev/null and b/project1/access/Add Book.png differ diff --git a/project1/access/Buy a book.png b/project1/access/Buy a book.png new file mode 100644 index 0000000..86705a2 Binary files /dev/null and b/project1/access/Buy a book.png differ diff --git a/project1/access/Display All Books.png b/project1/access/Display All Books.png new file mode 100644 index 0000000..17d5d5b Binary files /dev/null and b/project1/access/Display All Books.png differ diff --git a/project1/access/Display data of add book.png b/project1/access/Display data of add book.png new file mode 100644 index 0000000..0486d0d Binary files /dev/null and b/project1/access/Display data of add book.png differ diff --git a/project1/access/Search Book by Id.png b/project1/access/Search Book by Id.png new file mode 100644 index 0000000..48a4d43 Binary files /dev/null and b/project1/access/Search Book by Id.png differ diff --git a/project1/access/delete Book By Ib.png b/project1/access/delete Book By Ib.png new file mode 100644 index 0000000..aff4c91 Binary files /dev/null and b/project1/access/delete Book By Ib.png differ diff --git a/project1/access/menu.png b/project1/access/menu.png new file mode 100644 index 0000000..3fd5619 Binary files /dev/null and b/project1/access/menu.png differ diff --git a/project1/analysis_options.yaml b/project1/analysis_options.yaml new file mode 100644 index 0000000..dee8927 --- /dev/null +++ b/project1/analysis_options.yaml @@ -0,0 +1,30 @@ +# This file configures the static analysis results for your project (errors, +# warnings, and lints). +# +# This enables the 'recommended' set of lints from `package:lints`. +# This set helps identify many issues that may lead to problems when running +# or consuming Dart code, and enforces writing Dart using a single, idiomatic +# style and format. +# +# If you want a smaller set of lints you can change this to specify +# 'package:lints/core.yaml'. These are just the most critical lints +# (the recommended set includes the core lints). +# The core lints are also what is used by pub.dev for scoring packages. + +include: package:lints/recommended.yaml + +# Uncomment the following section to specify additional rules. + +# linter: +# rules: +# - camel_case_types + +# analyzer: +# exclude: +# - path/to/excluded/files/** + +# For more information about the core and recommended set of lints, see +# https://dart.dev/go/core-lints + +# For additional information about configuring this file, see +# https://dart.dev/guides/language/analysis-options diff --git a/project1/bin/myBooks.dart b/project1/bin/myBooks.dart new file mode 100644 index 0000000..2e46a51 --- /dev/null +++ b/project1/bin/myBooks.dart @@ -0,0 +1,34 @@ + final myBooks = [ + { "id": 101, + "name": "The-Little-Prince", + "author": "Antoine de Saint-Exupery", + "amount" : 10 , + "price": 100.0 + }, + { + "id": 102, + "name": "Little-women", + "author": "Louisa May Alcott", + "amount" : 8 , + "price": 100.0 + }, + { "id": 103, + "name": "The-Name-Jar", + "author": "Yangsook Choi", + "amount" : 3 , + "price": 80.0 + }, + { + "id": 104, + "name": "Goodnight-Good-Dog", + "author": "Mary Lyn Ray ", + "amount" : 6 , + "price": 50.0 + }, + { + "id": 105, + "name": "The-Cat-In-The-Hat", + "author": "Dr. Seuss ", + "amount" : 1, + "price": 30.0 + },]; \ No newline at end of file diff --git a/project1/bin/project1.dart b/project1/bin/project1.dart new file mode 100644 index 0000000..6288d8a --- /dev/null +++ b/project1/bin/project1.dart @@ -0,0 +1,226 @@ +import 'dart:io'; +import 'myBooks.dart'; + +void main() { + // Displaying menu + var count = 0; + while (count < 10) { + print("******************************************************************"); + print("******************** Welcome to Our library! ********************"); + print("-------------- "); + print(" Select From menu: :"); + print(" 1. Display All Books : 2. Add Books :"); + print(" 3. Delete Book: 4. Search Book by Id:"); + print(" 5. Buy a book : 0. Close library :( "); + print("-------------- "); + print("******************************************************************"); + String selected = stdin.readLineSync()!; + switch (selected) { + case "1": + displayBooks(); + break; + + case "2": + addNewBook(); + break; + + case "3": + deleteBookByIb(); + break; + + case "4": + searchBookById(); + break; + + case "5": + buyBook(); + break; + + case "0": + exit(0); + + default: + print("Choose again from the list ..."); + } + count++; + } +} +class Books { + int? id; + String? name; + String? author; + int amount =0; + double price = 0.0; + Books( + { this.id, + this.name, + this.author, + this.amount =0 , + this.price =0.0 ,}); + displayData() { + print(" Id of book :$id Name of book: $name "); + print(" Author :$author amount of book : $amount "); + print(" Price of book :$price SAR "); + + } +} + // funtion that display Books +displayBooks() { + print("==================================================================="); + print("====================> Display All Books! <========================="); + List listBooks = []; + for (var element in myBooks) { + listBooks.add(Books( + id: element["id"] as int, + name: element["name"] as String, + author: element["author"] as String , + amount: element["amount"] as int, + price: element["price"] as double )); + } + for (var item in listBooks) { + print("==================================================================="); + item.displayData(); + } + +} + //funtion that add books +addNewBook() { + print("==================================================================="); + print("====================> Add Books ! <================================="); + try { + print(" Enter Book ID :"); + int addId = int.parse(stdin.readLineSync()!); + print(" Enter name of Book :"); + String? addName = stdin.readLineSync()??"Abrar"; + print(" Enter name author of Book :"); + String addAuthor = stdin.readLineSync()??"Abrar"; + print(" Enter amount of Book :"); + int addAmount = int.parse(stdin.readLineSync()!); + print(" Enter price of Book :"); + double addPrice = double.parse(stdin.readLineSync()!); + print(" Done!!added Book .."); + final userMap = { + "id": addId, + "name": addName, + "author": addAuthor, + "amount": addAmount , + "price": addPrice , + }; + myBooks.add(userMap); + } catch (error) { + print("error"); + } + print("==================================================================="); +} +// funtion that delete Book By Ib +deleteBookByIb(){ + print("==================================================================="); + print("====================> Delete Book ! <=============================="); + try { + print(" Enter Book ID to delete :"); + int removeBookByIb = int.parse(stdin.readLineSync()!); + List listBooks = []; + for(int i =0 ;i x['id'] == removeBookByIb ); + print(" Done!!the Book Deleted .."); + break; + } else{ + print(" Thank you!! Not Book Deleted .."); + } + } else{ print("There is no such Book in Our library!!"); + break; +} + } + + } catch (error) { + print("error"); + } + print("==================================================================="); +} + //funtion that search Book By Id +searchBookById() { + print("==================================================================="); + print("====================> Search Book by Id! <========================="); + + print(" Enter Book ID to search :"); + int searchId = int.parse(stdin.readLineSync()!); + List listBooks = []; + for(int i =0 ;i x['id'] == searchId ); + print(listMyBooks); + break; + + } + else{ + print(" There is no such Book in Our library!! .."); + break; + } + } } + + //funtion that buy Book + buyBook(){ + print("==================================================================="); + print("====================> buy A Book! <========================="); + try { + print(" Enter ID of book do you want to buy :"); + int addId = int.parse(stdin.readLineSync()!); + print(" Enter amount(number) of Book :"); + int addAmount = int.parse(stdin.readLineSync()!); + + // myBooks.add(userMap); + for (var element in myBooks) { + Books book; Books( + id: element["id"] as int, + name: element["name"] as String, + author: element["author"] as String , + amount: element["amount"] as int, + price: element["price"] as double ); + + } + + + + //--- + + List listPrice = []; + int newPrice =0; + for(int i = 0 ;i=3.0.6 <3.3.0" diff --git a/project1/pubspec.yaml b/project1/pubspec.yaml new file mode 100644 index 0000000..f67b872 --- /dev/null +++ b/project1/pubspec.yaml @@ -0,0 +1,15 @@ +name: project1 +description: A sample command-line application. +version: 1.0.0 +# repository: https://github.com/my_org/my_repo + +environment: + sdk: ^3.0.6 + +# Add regular dependencies here. +dependencies: + # path: ^1.8.0 + +dev_dependencies: + lints: ^2.0.0 + test: ^1.21.0 diff --git a/project1/test/project1_test.dart b/project1/test/project1_test.dart new file mode 100644 index 0000000..eb827cc --- /dev/null +++ b/project1/test/project1_test.dart @@ -0,0 +1,8 @@ +import 'package:project1/project1.dart'; +import 'package:test/test.dart'; + +void main() { + test('calculate', () { + expect(calculate(), 42); + }); +}