Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions my_first_project/.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 my_first_project/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 1.0.0

- Initial version.
1 change: 1 addition & 0 deletions my_first_project/Project-dart-1
Submodule Project-dart-1 added at 999d3f
2 changes: 2 additions & 0 deletions my_first_project/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 my_first_project/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
27 changes: 27 additions & 0 deletions my_first_project/bin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
first ,the user should use the Command Line Interface(CLI)

here are some of the work i have done:

to Add a new book to the library you can press "1"
![Alt text](addNewBook.png)

to Display all books in the library you can press "2"
![Alt text](displayAllBooks.png)

if you want to Search a specific book you can press "3"
![Alt text](searchBooks.png)

if you want to Delete a book you can press "4"
![Alt text](deleteBooks.png)

to Purchase a book from the library press"5"
![Alt text](deleteBooks.png)

if you need to Edit the book information press "6"
![Alt text](editInfo.png)

when you're done with the library press "Q"
![Alt text](Quit.png)

Thank you..

24 changes: 24 additions & 0 deletions my_first_project/bin/book.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
class Book {
String bookTitle;
String authorName;
String briefDescription;
int publicationDate;
String category;
int availableCopies;
int price;

Book({
required this.bookTitle,
required this.authorName,
required this.briefDescription,
required this.publicationDate,
required this.category,
required this.availableCopies,
required this.price,
});

displayData() {
print(
"Book Title: $bookTitle ,Author Name: $authorName ,Brief Description: $briefDescription ,Publication Date: $publicationDate ,Category: $category ,Available Copies: $availableCopies ,Price: $price");
}
}
Binary file added my_first_project/bin/images/Quit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added my_first_project/bin/images/addNewBook.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added my_first_project/bin/images/deleteBooks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added my_first_project/bin/images/displayAllBooks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added my_first_project/bin/images/editInfo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added my_first_project/bin/images/purchaseBook.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added my_first_project/bin/images/searchBooks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
110 changes: 110 additions & 0 deletions my_first_project/bin/library.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import 'book.dart';

class Library {
List<Book> books = [
Book(
bookTitle: "The Blue Elephant",
authorName: "Ahmed Mourad",
briefDescription:
"A novel narrating the story of a psychiatrist dealing with a mysterious case at a mental hospital.",
publicationDate: 2014,
category: "Mystery/Thriller",
availableCopies: 5,
price: 10,
),
Book(
bookTitle: "The Handmaid's Tale",
authorName: "Margaret Atwood",
briefDescription:
"A dystopian novel depicting a future characterized by oppression and persecution",
publicationDate: 1985,
category: "Science Fiction/Dystopian",
availableCopies: 3,
price: 8,
),
Book(
bookTitle: "The Invisible Man",
authorName: "Mohamed Reda",
briefDescription:
"A collection of short stories addressing identity and existence.",
publicationDate: 2021,
category: "Short Stories/Fiction",
availableCopies: 8,
price: 12,
),
Book(
bookTitle: "Memory of the Body",
authorName: "Ahlam Mosteghanemi",
briefDescription:
"A novel revolving around a woman living between the past and the present",
publicationDate: 1993,
category: "Fiction/Romance",
availableCopies: 2,
price: 7,
),
Book(
bookTitle: "The Alchemist",
authorName: "Paulo Coelho",
briefDescription:
"A symbolic novel shedding light on the journey in search of true treasure.",
publicationDate: 1988,
category: "Fiction/Self-Help",
availableCopies: 6,
price: 9,
),
];

addBook(Book book) {
books.add(book);
}

List<Book> searchBooks(String keyword) {
return books.where((book) =>
book.bookTitle.contains(keyword) ||
book.authorName.contains(keyword)||
book.category.contains(keyword)).toList();
}

deleteBook(String title) {
for (int i = 0; i < books.length; i++) {
if (books[i].bookTitle == title) {
books.removeAt(i);
return true;
}
}
return false;
}
purchaseBook(String title) {
for (int i = 0; i < books.length; i++) {
if (books[i].bookTitle == title) {
if (books[i].availableCopies > 0) {
books[i].availableCopies--;
return true;
}
return false;
}
}
return false;
}

Book? getBookByTitle(String title) {
for (int i = 0; i < books.length; i++) {
if (books[i].bookTitle == title) {
return books[i];
}
}
return null;
}

displayAllBooks() {
if (books.isNotEmpty) {
print("All Books:");
for (var book in books) {
print("----------------");
book.displayData();
}
} else {
print("No books in the library.");
}
}
}
52 changes: 52 additions & 0 deletions my_first_project/bin/myData.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
final List myData = [
{
"Book Title": "The Blue Elephant",
"Author Name": "Ahmed Mourad",
" Brief Description":
"A novel narrating the story of a psychiatrist dealing with a mysterious case at a mental hospital.",
"Publication Date": 2014,
"Category": "Mystery/Thriller",
"Available Copies": 5,
"Price": 10
},
{
"Book Title": "The Handmaid's Tale",
"Author Name": "Margaret Atwood",
" Brief Description":
"A dystopian novel depicting a future characterized by oppression and persecution",
"Publication Date": 1985,
"Category": "Science Fiction/Dystopian",
"Available Copies": 3,
"Price": 8
},
{
"Book Title": "The Invisible Man",
"Author Name": "Mohamed Reda",
" Brief Description":
"A collection of short stories addressing identity and existence.",
"Publication Date": 2021,
"Category": "Short Stories/Fiction",
"Available Copies": 8,
"Price": 12
},
{
"Book Title": "Memory of the Body",
"Author Name": "Ahlam Mosteghanemi",
" Brief Description":
"A novel revolving around a woman living between the past and the present",
"Publication Date": 1993,
"Category": "Fiction/Romance",
"Available Copies": 2,
"Price": 7
},
{
"Book Title": "The Alchemist",
"Author Name": "Paulo Coelho",
" Brief Description":
"A symbolic novel shedding light on the journey in search of true treasure.",
"Publication Date": 1988,
"Category": "Fiction/Self-Help",
"Available Copies": 6,
"Price": 9
}
];
Loading