Skip to content

Commit

Permalink
fixed some bugs(IB)
Browse files Browse the repository at this point in the history
  • Loading branch information
IBrahem-Elyamany committed Dec 21, 2023
1 parent c62c75f commit 87c39df
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 26 deletions.
25 changes: 10 additions & 15 deletions .idea/workspace.xml

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

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
7 changes: 4 additions & 3 deletions data/datafiles/reviews_data.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
14,,,16,,,14,,,3,,,4,,,ghj
14,,,16,,,14,,,6,,,3,,,jjoo
14,,,16,,,14,,,2,,,5,,,hbjk
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
11 changes: 6 additions & 5 deletions src/main/java/com/asu/librarysystem/BookController.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ 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(2, book.getId(), 3, "I don't love this book");
// c
Library.getReviewHandler().addReview(2, book.getId(), 1, "I don't love this book");
ArrayList<Integer> ratings = Library.getReviewHandler().getBookRatings(book.getId());
setRatings(ratings);

InputStream stream1 = new FileInputStream("data/bookSceneAssets/Rating_icons/1_star.png");
InputStream stream2 = new FileInputStream("data/bookSceneAssets/Rating_icons/2_stars.png");
Expand Down Expand Up @@ -387,7 +388,7 @@ private void showComments(ArrayList<Review> comments) throws FileNotFoundExcepti


Label username = new Label();
String name=null ;


// ArrayList<Borrower> borrowers = Library.getBorrowers();
// ArrayList<Customer> customers = Library.getCustomers();
Expand All @@ -398,9 +399,9 @@ private void showComments(ArrayList<Review> comments) throws FileNotFoundExcepti
// name= Library.searchCustomerByID(comment.getReviewerId()).getUserName();
// }

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

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

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/asu/librarysystem/MainApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ public static void main(String[] args) {
// borrower.addTransaction(book3);
// borrower.addTransaction(book5);
// borrower.addTransaction(book9);
//
// Library.writeLibrary();

// Library.writeLibrary();

Library.readLibrary();

Expand Down
18 changes: 17 additions & 1 deletion src/main/java/com/asu/librarysystem/ReviewHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,24 @@ private Review findReview(int reviewerId, int bookId) {
else
return reviews.get(index);
}
public void addReview(int id, int reviewerId, int bookId, int rating, String text) {
Review review = findReview(reviewerId, bookId);
if (review.getReviewerId() != -1) {
updateReview(reviewerId, bookId, rating, text);
return;
}
review = new Review(id,reviewerId, bookId, rating, text);

reviews.add(review);
if (!bookRatings.containsKey(bookId)) {
bookRatings.put(bookId, new ArrayList<Integer>());
for (int i = 0; i < 6; i++)
bookRatings.get(bookId).add(0);
}
addBookRating(bookId, review.getRating());
}
public void addReview(Review review) {
addReview(review.getId(),review.getBookId(),review.getRating(),review.getText());
addReview(review.getId(),review.getReviewerId(),review.getBookId(),review.getRating(),review.getText());
}
public ArrayList<Review> getReviews(){
return reviews;
Expand Down

0 comments on commit 87c39df

Please sign in to comment.