-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from HosTheRockJohnson/main
Added Notifications and its Gui and added transactions Gui
- Loading branch information
Showing
27 changed files
with
1,713 additions
and
1,041 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
.idea/shelf/Uncommitted_changes_before_Update_at_20_12_2023_6_34_pm_[Changes]/shelved.patch
Large diffs are not rendered by default.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
.idea/shelf/Uncommitted_changes_before_Update_at_20_12_2023_6_34_pm__Changes_.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
// | ||
// } | ||
} |
Oops, something went wrong.