Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
25e9564
Lama Aldhafeeri
Lama-Aldhafeeri Jul 29, 2023
535f1be
Lama Aldhafeeri
Lama-Aldhafeeri Jul 29, 2023
283229f
Lama Aldhafeeri
Lama-Aldhafeeri Jul 30, 2023
a781a12
Lama Aldhafeeri
Lama-Aldhafeeri Jul 30, 2023
c77e61c
Lama Aldhafeeri
Lama-Aldhafeeri Jul 30, 2023
21180d9
Lama Aldhafeeri
Lama-Aldhafeeri Jul 30, 2023
d4f0f91
Lama Aldhafeeri
Lama-Aldhafeeri Jul 30, 2023
5cf4d78
Lama Aldhafeeri
Lama-Aldhafeeri Jul 30, 2023
0b799bc
Lama Aldhafeeri
Lama-Aldhafeeri Jul 30, 2023
e468ef1
Lama Aldhafeeri
Lama-Aldhafeeri Jul 30, 2023
fcc3d0b
Lama Aldhafeeri
Lama-Aldhafeeri Jul 30, 2023
e886ea8
Lama Aldhafeeri
Lama-Aldhafeeri Jul 30, 2023
97434d6
Lama Aldhafeeri
Lama-Aldhafeeri Jul 30, 2023
952a1a1
Lama Aldhafeeri
Lama-Aldhafeeri Jul 30, 2023
d91c0f4
Lama Aldhafeeri
Lama-Aldhafeeri Jul 30, 2023
c46e6db
Lama Aldhafeeri
Lama-Aldhafeeri Jul 30, 2023
3488bd6
Lama Aldhafeeri
Lama-Aldhafeeri Jul 30, 2023
c99164e
Lama Aldhafeeri
Lama-Aldhafeeri Jul 30, 2023
84d9cdf
Lama Aldhafeeri
Lama-Aldhafeeri Jul 30, 2023
542b0c8
Update README.md
Lama-Aldhafeeri Jul 30, 2023
31dc894
Update README.md
Lama-Aldhafeeri Jul 30, 2023
7390019
Lama Aldhafeeri
Lama-Aldhafeeri Jul 30, 2023
04df055
Update README.md
Lama-Aldhafeeri Jul 30, 2023
8404154
Lama Aldhafeeri
Lama-Aldhafeeri Jul 30, 2023
b0c5f8e
Update README.md
Lama-Aldhafeeri Jul 30, 2023
5156471
Delete image-10.png
Lama-Aldhafeeri Jul 30, 2023
3abf544
Delete image-11.png
Lama-Aldhafeeri Jul 30, 2023
0f60503
Delete image.png
Lama-Aldhafeeri Jul 30, 2023
1e8d564
Delete image-9.png
Lama-Aldhafeeri Jul 30, 2023
60be029
Delete image-12.png
Lama-Aldhafeeri Jul 30, 2023
284794e
Delete image-13.png
Lama-Aldhafeeri Jul 30, 2023
37d4eb6
Delete image-14.png
Lama-Aldhafeeri Jul 30, 2023
b62d361
Delete image-15.png
Lama-Aldhafeeri Jul 30, 2023
824008c
Delete image-8.png
Lama-Aldhafeeri Jul 30, 2023
78e39e0
Delete image-7.png
Lama-Aldhafeeri Jul 30, 2023
bceac88
Delete image-6.png
Lama-Aldhafeeri Jul 30, 2023
ab56ff8
Delete image-16.png
Lama-Aldhafeeri Jul 30, 2023
da824ba
Delete image-17.png
Lama-Aldhafeeri Jul 30, 2023
078be1b
Delete image-18.png
Lama-Aldhafeeri Jul 30, 2023
e4b46ec
Delete image-2.png
Lama-Aldhafeeri Jul 30, 2023
4847eb0
Delete image-3.png
Lama-Aldhafeeri Jul 30, 2023
fa1629f
Delete image-4.png
Lama-Aldhafeeri Jul 30, 2023
0347f83
Delete image-5.png
Lama-Aldhafeeri Jul 30, 2023
e2a3ac0
Lama Aldhafeeri
Lama-Aldhafeeri Jul 30, 2023
5915b12
Update README.md
Lama-Aldhafeeri Jul 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 76 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,83 +1,115 @@
# Project #1 - Library Project using Dart
# Project #1 - Library Project using Dart - Lama Aldhafeeri

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:
I enjoyed developing library project in dart. that manage a library book inventory and user interactions.

The main functions in this project are:
1. **Let user Add New Book**
2. **Let user delete Book**
3. **Let user edit Book information**
4. **Let user query Books**
5. **The user can purchase a book and then the invoice details will be shown to him/her**

## Description:
Secondary objective:
1. **Let user view all Book Categories and then choes one of them to view books related to chosen categorie**

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.
2. **the user can view number of purchases**

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.
## Project outputs:
First, if the user choose "1" then all Categories displayed.

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.
![image](https://github.com/Lama-Aldhafeeri/Project-dart-1/assets/84765301/faca9f40-7d05-4219-8d6a-b0b40ae8026c)

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.
Then the user can write one of categories to get all related books.

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.
![image](https://github.com/Lama-Aldhafeeri/Project-dart-1/assets/84765301/300e890e-b25d-4de3-9ae7-138f2f519394)

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.

Number "2" for Query Books by writing title or author or category of the book exist it will display.

![image](https://github.com/Lama-Aldhafeeri/Project-dart-1/assets/84765301/162ddc8b-4c96-4028-a682-8331e5a7b2c6)

## 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.
If the book not exist message below appear.

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.
![image](https://github.com/Lama-Aldhafeeri/Project-dart-1/assets/84765301/a0c1967e-77ab-4a1b-bd25-f5a117b13838)

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.
Number "3" for adding new book:
If the user entered new book that is not exist in the data then then the system will ask him/her to fill all required data

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.
![image](https://github.com/Lama-Aldhafeeri/Project-dart-1/assets/84765301/7e7d3f8b-6936-442b-b80c-cb2118890069)

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.
check if the book is added:

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.
![image](https://github.com/Lama-Aldhafeeri/Project-dart-1/assets/84765301/e6126d3b-3a97-4e8c-b38b-e69da2f77527)

## Ideas for Extra Credit:
Then if the book already exist then the message below appear that gives the user choose to only increase number of copics

- **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.
-
![image](https://github.com/Lama-Aldhafeeri/Project-dart-1/assets/84765301/39bc50f7-a52e-4adf-be5c-fd86ab7dfa35)

## Delivery Requirements:

- **Language**: The project should be written in Dart language.
once the user enter "y" then the system will update the available copies depend on number of copies entered by user

- **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.
![image](https://github.com/Lama-Aldhafeeri/Project-dart-1/assets/84765301/42063a3e-5fcf-48d4-8998-5319222a59f0)


- **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.
before:

- **Screenshots**: Include relevant screenshots of the app to showcase its appearance and functionalities. Visuals can help users understand the app's design and layout.
![image](https://github.com/Lama-Aldhafeeri/Project-dart-1/assets/84765301/b0942e1f-9929-45ff-82b4-8a20c0ced09b)

## Schedule & Deadlines:

- Exam Start Date: 27/7/2023 - 3:00 PM
- Exam Submission Deadline: 30/7/2023 – 11:59 AM
after:

## Evaluation Criteria:
![image](https://github.com/Lama-Aldhafeeri/Project-dart-1/assets/84765301/b2d9f761-6304-4db8-b788-1ce6789524a6)

The project will be evaluated based on the following criteria:

- **Completion**: The extent to which the project meets all the minimum requirements, including the extra credit ideas if implemented.

- **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.
Number "4" for deleting:

- **Use of Programming Concepts**: How well you utilize programming concepts such as classes, abstracts, functions, and other relevant techniques.
![image](https://github.com/Lama-Aldhafeeri/Project-dart-1/assets/84765301/3962fe05-6b46-4d3a-a632-ffa638fa3be2)

## Resources

- [Dart Tutorials](https://dart.dev/tutorials)
check if the book is deleted:

![image](https://github.com/Lama-Aldhafeeri/Project-dart-1/assets/84765301/379efa14-903a-4ebf-b9fe-eff11a3c3298)


Number "5" for editing:

![image](https://github.com/Lama-Aldhafeeri/Project-dart-1/assets/84765301/5f8e0d15-65ed-4850-a9ea-086ac73161f8)


check:

![image](https://github.com/Lama-Aldhafeeri/Project-dart-1/assets/84765301/39b4a109-0549-42fe-aae8-afc60f8a980f)


if the user entered invalid data or empty data or entered name of book that does not exist those messages below appear:

![image](https://github.com/Lama-Aldhafeeri/Project-dart-1/assets/84765301/6a25abb2-6f3d-4576-8141-f52b76e3e667)


Number "6" for Purchase:
if the user try to buy more than the copies existing the system will alert him/her of number of available copies:

![image](https://github.com/Lama-Aldhafeeri/Project-dart-1/assets/84765301/c3e72625-36a5-4604-b648-5db295c75ab7)


![image](https://github.com/Lama-Aldhafeeri/Project-dart-1/assets/84765301/7217a29c-1955-42ae-9cb8-c8883eb44a4c)


After buying all available copies the number of copies will decrease so the user won't be able to buy it

![image](https://github.com/Lama-Aldhafeeri/Project-dart-1/assets/84765301/f66c552d-b11f-4bb1-8edd-20ae844a1b4b)



last thing the user can inquire about number of purchased by chose number "7"
![image](https://github.com/Lama-Aldhafeeri/Project-dart-1/assets/84765301/2378563e-2ec4-4a38-833e-5eec40b65780)


Number "8" for exit.

Good luck with the project, and feel free to ask any additional questions if needed!
6 changes: 6 additions & 0 deletions project-1/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Files and directories created by pub.
.dart_tool/
.packages

# Conventional directory for build output.
build/
3 changes: 3 additions & 0 deletions project-1/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 1.0.0

- Initial version.
2 changes: 2 additions & 0 deletions project-1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
A sample command-line application with an entrypoint in `bin/`, library code
in `lib/`, and example unit test in `test/`.
30 changes: 30 additions & 0 deletions project-1/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -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
53 changes: 53 additions & 0 deletions project-1/bin/addNewBook.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import 'classes.dart';
import 'main.dart';
import 'data.dart';
import 'dart:io';

/// Check if the book exist then add new book to books data or increase number of copies
addNewBook() {
Map newBook;

do {
try {
print("Enter the title of the book you want to add: (e for exit)");
String userInput = stdin.readLineSync()!;

if (userInput == "e" || userInput == "E") {
break;
} else if (userInput == "") {
// make sure that user will not enter empty data
print("please enter valid title to delete");
} else if (titles.contains(userInput)) {
// if the book exists then call increaseTheCopies
increaseTheCopies(title: userInput);
} else if (!titles.contains(userInput)) {
newBook =
queryFromUser(title: userInput); // Get all required data from user
booksData.add(newBook);
print("Added successfully");
}
} on FormatException {
print("please enter valid number");
} catch (error) {
print("please make sure you entered correct data");
}
} while (true);
}

/// increase number of copies of the book
increaseTheCopies({required title}) {
for (var book in booksList) {
if (book.title == title) {
print("The book is already exist you want to increase the copics [y/n]");
String confirm = stdin.readLineSync()!;
if (confirm == "y" || confirm == "Y") {
print("How many copics?");
int copics = int.parse(stdin.readLineSync()!);
book.numberOfCopies += copics;
print("Updated successfully");
} else if (confirm == "n" || confirm == "N") {
break;
}
}
}
}
99 changes: 99 additions & 0 deletions project-1/bin/classes.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
class Library {
String? name;

Library({this.name});
}

class Book extends Library {
late String title;
late String author;
late String category;
late int price;
late int numberOfCopies;
String? description;
String? publicationYear;

/// counter for all purchase in the library
static int counterForAllPurchase = 0;

Book(
{String? libarayName,
required this.title,
required this.author,
required this.category,
required this.numberOfCopies,
required this.price,
this.description,
this.publicationYear})
: super(name: libarayName);

getNumberOfCopies() {
if (numberOfCopies <= 0) {
numberOfCopies--;
return "sold out";
} else if (numberOfCopies <= 3) {
return "Only left $numberOfCopies";
} else {
return "There is $numberOfCopies books";
}
}

/// edit book attribute
editBook({
String? newTitle,
String? newAuthor,
String? newCategory,
String? newDescription,
String? newPublicationYear,
int? newNumberOfCopies,
int? newPrice,
}) {
if (newTitle != null) {
title = newTitle;
}
if (newAuthor != null) {
author = newAuthor;
}
if (newCategory != null) {
category = newCategory;
}
if (newNumberOfCopies != null) {
numberOfCopies = newNumberOfCopies;
}
if (newPrice != null) {
price = newPrice;
}
if (newPrice != null) {
price = newPrice;
}
if (newDescription != null) {
description = newDescription;
}
if (newPublicationYear != null) {
publicationYear = newPublicationYear;
}
}

/// Decrease number of copies and then return message
purchaseBook(int quantity) {
if (numberOfCopies > 0) {
numberOfCopies = numberOfCopies - quantity;
return "The purchase was completed successfully";
} else {
return "Sorry, the book is sold out";
}
}

/// print invoice details
invoice(int quantity) {
var totalPrice = price * quantity;
print("Item \t\t| Uint Price \t| quantity \t| Total Price");
print("$title \t\t| $price \t| $quantity \t| $totalPrice");
}

/// print all book attribute
display() {
print(
" Book title: $title \n The author: $author \n Category: $category \n Description: $description \n Publication Year: $publicationYear \n Price: $price \n ${getNumberOfCopies()}");
}
}
Loading