Skip to content

Commit

Permalink
Merge pull request #37 from IBrahem-Elyamany/main
Browse files Browse the repository at this point in the history
latest version of the discussion (IB)
  • Loading branch information
ahmedsiam0 authored Dec 22, 2023
2 parents 8d3b1da + 87c39df commit 9acdc38
Show file tree
Hide file tree
Showing 22 changed files with 550 additions and 213 deletions.
76 changes: 63 additions & 13 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified data/covers/11.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/covers/12.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions data/datafiles/books_data.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
10,,,1,,,Harry Potter and the Prisoner of Azkaban,,,J. K. Rowling,,,2023,,,true,,,200,,,4,,,Harry Potter and the Prisoner of Azkaban is a fantasy novel written by British author J. K. Rowling and is the third in the Harry Potter series. The book follows Harry Potter, a young wizard, in his third year at Hogwarts School of Witchcraft and Wizardry. Along with friends Ronald Weasley and Hermione Granger, Harry investigates Sirius Black, an escaped prisoner from Azkaban, the wizard prison, believed to be one of Lord Voldemort's old allies.,,,E:\ibrahem\oop\project6\1\library-system2\data\covers\1.jpg
HORROR,,,
10,,,2,,,Harry Potter and the Chamber of Secrets,,,J. K. Rowling,,,2020,,,true,,,200,,,3,,,Harry Potter and the Chamber of Secrets is a fantasy novel written by British author J. K. Rowling and the second novel in the Harry Potter series. The plot follows Harry's second year at Hogwarts School of Witchcraft and Wizardry, during which a series of messages on the walls of the school's corridors warn that the "Chamber of Secrets" has been opened and that the "heir of Slytherin" would kill all pupils who do not come from all-magical families. These threats are found after attacks that leave residents of the school petrified. Throughout the year, Harry and his friends Ron and Hermione investigate the attacks.,,,E:\ibrahem\oop\project6\1\library-system2\data\covers\2.jpg
ADVENTURE,,,
10,,,3,,,The Alchemist ,,,Paulo Coelho ,,,2021,,,true,,,200,,,1,,,The Alchemist (Portuguese: O Alquimista) is a novel by Brazilian author Paulo Coelho which was first published in 1988. Originally written in Portuguese, it became a widely translated international bestseller.[1][2] The story follows the shepherd boy Santiago in his journey across northern Africa to the pyramids of Egypt after he dreams of finding a treasure there.,,,E:\ibrahem\oop\project6\1\library-system2\data\covers\3.jpg
ADVENTURE,,,
10,,,4,,,A Tale of Two Cities,,,Charles Dickens,,,2023,,,true,,,200,,,4,,,A Tale of Two Cities is a historical novel published in 1859 by Charles Dickens, set in London and Paris before and during the French Revolution. The novel tells the story of the French Doctor Manette, his 18-year-long imprisonment in the Bastille in Paris, and his release to live in London with his daughter Lucie whom he had never met. The story is set against the conditions that led up to the French Revolution and the Reign of Terror.,,,E:\ibrahem\oop\project6\1\library-system2\data\covers\4.jpg
ADVENTURE,,,
10,,,5,,,The Little Prince ,,,Antoine de Saint-Exupéry,,,2020,,,true,,,200,,,2,,,The Little Prince (French: Le Petit Prince, pronounced [lə p(ə)ti pʁɛ̃s]) is a novella written and illustrated by French aristocrat, writer, and military pilot Antoine de Saint-Exupéry. It was first published in English and French in the United States by Reynal & Hitchcock in April 1943 and was published posthumously in France following liberation; Saint-Exupéry's works had been banned by the Vichy Regime. The story follows a young prince who visits various planets, including Earth, and addresses themes of loneliness, friendship, love, and loss. Despite its style as a children's book, The Little Prince makes observations about life, adults, and human nature.,,,E:\ibrahem\oop\project6\1\library-system2\data\covers\5.jpg
ADVENTURE,,,
10,,,6,,,Harry Potter and the Philosopher's Stone,,,J. K. Rowling,,,2021,,,true,,,200,,,2,,,Harry Potter and the Philosopher's Stone is a fantasy novel written by British author J. K. Rowling. The first novel in the Harry Potter series and Rowling's debut novel, it follows Harry Potter, a young wizard who discovers his magical heritage on his eleventh birthday, when he receives a letter of acceptance to Hogwarts School of Witchcraft and Wizardry. Harry makes close friends and a few enemies during his first year at the school and with the help of his friends, Ron Weasley and Hermione Granger, he faces an attempted comeback by the dark wizard Lord Voldemort, who killed Harry's parents, but failed to kill Harry when he was just 15 months old.,,,E:\ibrahem\oop\project6\1\library-system2\data\covers\6.jpg
ADVENTURE,,,
10,,,7,,,And Then There Were None,,,Agatha Christie,,,2023,,,true,,,200,,,4,,,And Then There Were None is a mystery novel by the English writer Agatha Christie, who described it as the most difficult of her books to write.[2] It was first published in the United Kingdom by the Collins Crime Club on 6 November 1939, as Ten Little Niggers,[3] after an 1869 minstrel song that serves as a major plot element.[4][5] The US edition was released in January 1940 with the title And Then There Were None, taken from the last five words of the song.[6] Successive American reprints and adaptations use that title, though American Pocket Books paperbacks used the title Ten Little Indians between 1964 and 1986. UK editions continued to use the original title until 1985.[7],,,E:\ibrahem\oop\project6\1\library-system2\data\covers\7.jpg
ADVENTURE,,,
10,,,8,,,The Hobbit,,,J. R. R. Tolkien,,,2020,,,true,,,200,,,3,,,The Hobbit, or There and Back Again is a children's fantasy novel by English author J. R. R. Tolkien. It was published in 1937 to wide critical acclaim, being nominated for the Carnegie Medal and awarded a prize from the New York Herald Tribune for best juvenile fiction. The book is recognized as a classic in children's literature and is one of the best-selling books of all time, with over 100 million copies sold.,,,E:\ibrahem\oop\project6\1\library-system2\data\covers\8.jpg
ADVENTURE,,,HORROR,,,
10,,,9,,,She: A History of Adventure,,,H. Rider Haggard,,,2021,,,true,,,200,,,1,,,She, subtitled A History of Adventure, is a novel by the English writer H. Rider Haggard, published in book form in 1887 following serialisation in The Graphic magazine between October 1886 and January 1887. She was extraordinarily popular upon its release and has never been out of print.,,,E:\ibrahem\oop\project6\1\library-system2\data\covers\9.jpg
ADVENTURE,,,
10,,,10,,,The Da Vinci Code,,,Dan Brown,,,2021,,,true,,,200,,,2,,,The Da Vinci Code is a 2003 mystery thriller novel by Dan Brown. It is Brown's second novel to include the character Robert Langdon: the first was his 2000 novel Angels & Demons. The Da Vinci Code follows symbologist Robert Langdon and cryptologist Sophie Neveu after a murder in the Louvre Museum in Paris causes them to become involved in a battle between the Priory of Sion and Opus Dei over the possibility of Jesus Christ and Mary Magdalene having had a child together.,,,E:\ibrahem\oop\project6\1\library-system2\data\covers\10.jpg
ADVENTURE,,,
1 change: 1 addition & 0 deletions data/datafiles/borrowers_data.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5,,,3,,,user2,,,user2,,,111
1 change: 1 addition & 0 deletions data/datafiles/customers_data.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5,,,2,,,user1,,,user1,,,111
2 changes: 2 additions & 0 deletions data/datafiles/discount_data.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Lucky0,,,50.0
Lucky1,,,100.0
5 changes: 5 additions & 0 deletions data/datafiles/order_data_user1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
5,,,1,,,1,,,2
5,,,2,,,2,,,2
5,,,3,,,3,,,1
5,,,4,,,5,,,2
5,,,5,,,7,,,2
4 changes: 4 additions & 0 deletions data/datafiles/reviews_data.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
11,,,2,,,2,,,1,,,1,,,I don't love this book
11,,,4,,,2,,,10,,,3,,,I don't love this book
11,,,6,,,3,,,1,,,4,,,good
11,,,8,,,3,,,10,,,1,,,bad
3 changes: 3 additions & 0 deletions data/datafiles/transaction_data_user2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
3,,,3,,,3,,,3,,,2023-12-21,,,2024-01-21
3,,,3,,,3,,,3,,,2023-12-21,,,2024-01-21
3,,,3,,,3,,,3,,,2023-12-21,,,2024-01-21
12 changes: 12 additions & 0 deletions src/main/java/com/asu/librarysystem/Account.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ public Account(String userName, String password, String phoneNumber) {


}
public Account(int id, String userName, String password, String phoneNumber) {
this.id=id;
this.userName = userName;
this.Password = password;
this.phoneNumber = phoneNumber;
}
public void setIdCounter(int idCounter) {
this.idCounter=idCounter;
}
public int getIdCounter(){
return idCounter;
}

public void setPassword(String password) {
Password = password;
Expand Down
27 changes: 23 additions & 4 deletions src/main/java/com/asu/librarysystem/Book.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,41 @@ public class Book {



public Book(String title, String author, int publicationYear, boolean status, int price, int quantity
, String description, String coverPath, Category[] categories) {
public Book(int id,String title, String author, int publicationYear, boolean status, int price, int quantity, String descreption, String coverPath, ArrayList<Category> categories){
this.id=id;
this.title = title;
this.author = author;
this.publicationYear = publicationYear;
this.status = status;
this.price = price;
this.quantity = quantity;
this.description = descreption;
setCover(coverPath);
this.categories=categories;
}
public Book(String title, String author, int publicationYear, boolean status, int price, int quantity, String descreption, String coverPath){
this.id = ++idCounter;
this.title = title;
this.author = author;
this.publicationYear = publicationYear;
this.status = status;
this.price = price;
this.quantity = quantity;
this.description = description;

this.description = descreption;
setCover(coverPath);
}

public Book(String title, String author, int publicationYear, boolean status, int price, int quantity, String descreption, String coverPath, Category[] categories) {
this( title, author, publicationYear, status, price, quantity, descreption, coverPath);
this.categories = new ArrayList<Category>(Arrays.asList(categories));
}

public int getIdCounter() {
return idCounter;
}
public void setIdCounter(int idCounter) {
this.idCounter = idCounter;
}
public int getId() {
return id;
}
Expand Down
25 changes: 21 additions & 4 deletions src/main/java/com/asu/librarysystem/BookController.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import javafx.stage.Stage;

Expand Down Expand Up @@ -84,7 +85,7 @@ public void setScene(Book book) throws IOException {
setProperties(book.getTitle(), book.getAuthor(), Integer.toString(book.getPublicationYear())
, book.getDescription(), book.getPrice(), book.getQuantity());

Library.getReviewHandler().addReview(1, book.getId(), 3, "I don't love this book");
Library.getReviewHandler().addReview(2, book.getId(), 1, "I don't love this book");
ArrayList<Integer> ratings = Library.getReviewHandler().getBookRatings(book.getId());
setRatings(ratings);

Expand Down Expand Up @@ -270,7 +271,7 @@ private void showRecommendations() throws IOException {
for (Book book : availableBooks){
if (counter == 6) break;

if (findingCommonCategories(book)){
if (findingCommonCategories(book) && book.getId() != currentBook.getId() && book.isAvailable()){
FXMLLoader fxmlLoader=new FXMLLoader();
fxmlLoader.setLocation(getClass().getResource("Book-View-Card.fxml"));

Expand Down Expand Up @@ -333,6 +334,9 @@ public void submitReview(ActionEvent event) throws FileNotFoundException {
Account activeUser = Library.getActiveAccount();
Library.getReviewHandler().addReview(activeUser.getId(), currentBook.getId(),
ratingOptions.getValue(), reviewTextArea.getText());
reviewTextArea.setText("");
warningMessage.setFill(Color.GREEN);
warningMessage.setText("Review added successfully");
System.out.println("review added");

showComments(Library.getReviewHandler().getBookReviews(currentBook.getId()));
Expand Down Expand Up @@ -384,13 +388,26 @@ private void showComments(ArrayList<Review> comments) throws FileNotFoundExcepti


Label username = new Label();
username.setText(Integer.toString(comment.getReviewerId()));


// ArrayList<Borrower> borrowers = Library.getBorrowers();
// ArrayList<Customer> customers = Library.getCustomers();
// if(Library.searchCustomerByID(comment.getReviewerId())==null){
// name= Library.searchBorrwerByID(comment.getReviewerId()).getUserName();
// }
// else {
// name= Library.searchCustomerByID(comment.getReviewerId()).getUserName();
// }

String name=Library.searchAccountById(comment.getReviewerId()).getUserName();

username.setText(name);//String.valueOf(comment.getReviewerId())
username.setStyle("-fx-font-weight: 200;");
username.setStyle("-fx-font-size: 20px;");


ImageView rate = new ImageView();
rate.setFitWidth(228);
rate.setFitWidth(190);//228
rate.setFitHeight(50);
if (comment.getRating() == 1){
rate.setImage(oneStar);
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/asu/librarysystem/Borrower.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.asu.librarysystem;

import java.time.LocalDate;
import java.util.ArrayList;

import java.util.Date;
Expand All @@ -20,6 +21,12 @@ public Borrower(String borrowerName, String password, String PhoneNumber) {
assignBefore = false;
}

public Borrower(int id,String borrowerName, String password, String PhoneNumber) {
super(id,borrowerName, password, PhoneNumber);
borrowerTransactions = new ArrayList<>();
assignBefore = false;
}

public void addReservation(Book book)
{
reservedBooks.add(book);
Expand All @@ -43,6 +50,12 @@ public void addTransaction(Book book) {
getReservedBooks().remove(book);
}
}
public void addTransaction(int bookId, int borrowerId, LocalDate borrowDate, LocalDate returnDate) {
borrowerTransactions.add(new Transaction(bookId,borrowerId, getId(), borrowDate, returnDate));
}
public void addTransaction(Transaction transaction){
addTransaction(transaction.getBookId(),transaction.getBorrowerId(),transaction.getBorrowDate(),transaction.getReturnDate());
}

public boolean deleteTransaction(int transactionId) {
try {
Expand Down
Loading

0 comments on commit 9acdc38

Please sign in to comment.