Skip to content

Commit

Permalink
Merge pull request #33 from HosTheRockJohnson/main
Browse files Browse the repository at this point in the history
Added Notifications and its Gui and added transactions Gui
  • Loading branch information
ahmedsiam0 authored Dec 21, 2023
2 parents df89e1d + a241f1a commit e1e72e4
Show file tree
Hide file tree
Showing 27 changed files with 1,713 additions and 1,041 deletions.

Large diffs are not rendered by default.

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

246 changes: 123 additions & 123 deletions .idea/uiDesigner.xml

Large diffs are not rendered by default.

37 changes: 16 additions & 21 deletions .idea/workspace.xml

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

Binary file removed data/covers/1.jpg
Binary file not shown.
Binary file removed data/covers/2.jpg
Binary file not shown.
Binary file removed data/covers/3.jpg
Binary file not shown.
Binary file removed data/covers/4.jpg
Binary file not shown.
16 changes: 8 additions & 8 deletions src/main/java/com/asu/librarysystem/Admin.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.asu.librarysystem;

public class Admin extends Account {

public Admin( String adminName, String Password, String PhoneNumber) {
super( adminName, Password, PhoneNumber);
}

package com.asu.librarysystem;

public class Admin extends Account {

public Admin( String adminName, String Password, String PhoneNumber) {
super( adminName, Password, PhoneNumber);
}

}
5 changes: 5 additions & 0 deletions src/main/java/com/asu/librarysystem/BookController.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Objects;
import java.util.ResourceBundle;
import java.util.Stack;

Expand Down Expand Up @@ -65,6 +66,10 @@ public class BookController implements Initializable {
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
ratingOptions.setItems(optionsList);
notifyMe.setOnMouseClicked(mouseEvent -> {
Notifications notifications = new Notifications();
notifications.reservationConfirmation(currentBook);
});
}

public void setScene(Book book) throws IOException {
Expand Down
250 changes: 137 additions & 113 deletions src/main/java/com/asu/librarysystem/Borrower.java
Original file line number Diff line number Diff line change
@@ -1,113 +1,137 @@
package com.asu.librarysystem;

import java.util.ArrayList;

public class Borrower extends Account {
private double borrowerFines = 0;
private ArrayList<Transaction> borrowerTransactions;
public boolean assignBefore;
private int noOfBooks;
private boolean isAdmin = false;


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

public void addTransaction(Book book, int borrowDate, int returnDate) {
borrowerTransactions.add(new Transaction(book.getId(), getId(), borrowDate, returnDate));
}

public boolean deleteTransaction(int transactionId) {
try {
borrowerTransactions.remove(transactionId);
return true;
} catch (IndexOutOfBoundsException e) {
//System.out.println("cant delete because the index is out of bound");
return false;
}
}

public int searchTransactions(int transactionId) {
for (int i = 0; i < borrowerTransactions.size(); i++) {
if (borrowerTransactions.get(i).getTransactionId() == transactionId) {
return borrowerTransactions.get(i).getBorrowerId();
}
}
return -1;
}

public double finesIfLate() {
for (Transaction borrowerTransaction : borrowerTransactions) {
if (borrowerTransaction.getBorrowerId() == this.getId() && borrowerTransaction.getFines() >= 0) {
borrowerFines += borrowerTransaction.getFines();
}
}
return borrowerFines;
}

public void setAssignBefore(boolean assignBefore) {
if (!assignBefore)
this.assignBefore = true;
else
this.assignBefore = false;
}


public ArrayList<Transaction> getBorrowerTransactions() {
return borrowerTransactions;
}

public int getNoOfBooks() {
this.noOfBooks = this.getBorrowerTransactions().size();
return noOfBooks;
}

public boolean getAdmin() {
return isAdmin;
}
public void setAdmin(boolean admin) {
this.isAdmin = admin;
}

public ArrayList<Book> arrayOFTransactionBooks(){
ArrayList<Book> transactionBooksArrayList=new ArrayList<Book>();
for(int i=0;i<borrowerTransactions.size();i++) {
transactionBooksArrayList.add(Library.searchBookById(borrowerTransactions.get(i).getBookId()));
}
return transactionBooksArrayList;
}
// public void writeTransaction(){
// try {
// FileOutputStream write=new FileOutputStream("transaction_data.txt");
// for (Transaction obj : borrowerTransactions ) {
// String bookName=searchBookById(obj.getBookId()).getTitle();
// write.write((obj.getTransactionId()+","+bookName+","+obj.getBorrowerId()+","+obj.getBorrowDate()+","+obj.getReturnDate()+"\n").getBytes());
// }
// write.close();
// } catch (FileNotFoundException e) {
// System.out.println("can't write");
// } catch (IOException e) {
// System.out.println("can't write");
// }
// }

// public void readTransaction(){
// Scanner scanner = null;
// try {
// scanner = new Scanner(new FileInputStream("transaction_data.txt"));
// } catch (FileNotFoundException e) {
// System.out.println("can't read");
// }
//
// while (scanner.hasNextLine()) {
// String line = scanner.nextLine();
// String[] parts = line.split(",");
// Transaction transaction =new Transaction(searchBookByTitle(parts[1]).getId(),getId(),Integer.valueOf(parts[3]),Integer.valueOf(parts[4]));
// }
// scanner1.close();
//
// }
}
package com.asu.librarysystem;

import java.util.ArrayList;

import java.util.Date;
import java.util.Objects;

public class Borrower extends Account {
private double borrowerFines = 0;
private ArrayList<Transaction> borrowerTransactions;
private ArrayList<Book> reservedBooks = new ArrayList<>();
public boolean assignBefore;
private int noOfBooks;
private boolean isAdmin = false;


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

public void addReservation(Book book)
{
reservedBooks.add(book);
}

public ArrayList<Book> getReservedBooks() {
return reservedBooks;
}

public void addTransaction(Book book) {
borrowerTransactions.add(new Transaction(book, getId()));
book.setQuantity(book.getQuantity() - 1);
boolean bool = false;
for (int i = 0; i < getReservedBooks().size(); i++) {
if (getReservedBooks().get(i).getId() == book.getId()) {
bool = true;
break;
}
}
if (bool) {
getReservedBooks().remove(book);
}
}

public boolean deleteTransaction(int transactionId) {
try {
borrowerTransactions.remove(transactionId);
return true;
} catch (IndexOutOfBoundsException e) {
//System.out.println("cant delete because the index is out of bound");
return false;
}
}

public int searchTransactions(int transactionId) {
for (int i = 0; i < borrowerTransactions.size(); i++) {
if (borrowerTransactions.get(i).getTransactionId() == transactionId) {
return borrowerTransactions.get(i).getBorrowerId();
}
}
return -1;
}

public double finesIfLate() {
for (Transaction borrowerTransaction : borrowerTransactions) {
if (borrowerTransaction.getBorrowerId() == this.getId() && borrowerTransaction.getFines() >= 0) {
borrowerFines += borrowerTransaction.getFines();
}
}
return borrowerFines;
}

public void setAssignBefore(boolean assignBefore) {
if (!assignBefore)
this.assignBefore = true;
else
this.assignBefore = false;
}


public ArrayList<Transaction> getBorrowerTransactions() {
return borrowerTransactions;
}

public int getNoOfBooks() {
this.noOfBooks = this.getBorrowerTransactions().size();
return noOfBooks;
}

public boolean getAdmin() {
return isAdmin;
}
public void setAdmin(boolean admin) {
this.isAdmin = admin;
}

public ArrayList<Book> arrayOFTransactionBooks(){
ArrayList<Book> transactionBooksArrayList=new ArrayList<Book>();
for(int i=0;i<borrowerTransactions.size();i++) {
transactionBooksArrayList.add(Library.searchBookById(borrowerTransactions.get(i).getBookId()));
}
return transactionBooksArrayList;
}
// public void writeTransaction(){
// try {
// FileOutputStream write=new FileOutputStream("transaction_data.txt");
// for (Transaction obj : borrowerTransactions ) {
// String bookName=searchBookById(obj.getBookId()).getTitle();
// write.write((obj.getTransactionId()+","+bookName+","+obj.getBorrowerId()+","+obj.getBorrowDate()+","+obj.getReturnDate()+"\n").getBytes());
// }
// write.close();
// } catch (FileNotFoundException e) {
// System.out.println("can't write");
// } catch (IOException e) {
// System.out.println("can't write");
// }
// }

// public void readTransaction(){
// Scanner scanner = null;
// try {
// scanner = new Scanner(new FileInputStream("transaction_data.txt"));
// } catch (FileNotFoundException e) {
// System.out.println("can't read");
// }
//
// while (scanner.hasNextLine()) {
// String line = scanner.nextLine();
// String[] parts = line.split(",");
// Transaction transaction =new Transaction(searchBookByTitle(parts[1]).getId(),getId(),Integer.valueOf(parts[3]),Integer.valueOf(parts[4]));
// }
// scanner1.close();
//
// }
}
Loading

0 comments on commit e1e72e4

Please sign in to comment.