-
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 #27 from ahmedsiam0/am-code
Merge Ahmad Muhammed's code
- Loading branch information
Showing
97 changed files
with
5,607 additions
and
146 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.asu.librarysystem; | ||
|
||
public abstract class Account { | ||
private static int idCounter = 0; | ||
private final int id; | ||
private String userName; | ||
private String Password; | ||
private String phoneNumber; | ||
|
||
|
||
|
||
public Account(String userName, String password, String phoneNumber) { | ||
this.userName = userName; | ||
this.id = ++idCounter; | ||
this.Password = password; | ||
this.phoneNumber = phoneNumber; | ||
|
||
|
||
} | ||
|
||
public void setPassword(String password) { | ||
Password = password; | ||
} | ||
|
||
public void setUserName(String userName) { | ||
this.userName = userName; | ||
} | ||
|
||
public void setPhoneNumber(String phoneNumber) { | ||
this.phoneNumber = phoneNumber; | ||
} | ||
|
||
public int getId() { | ||
return id; | ||
} | ||
|
||
public String getUserName() { | ||
return userName; | ||
} | ||
|
||
public String getPassword() { | ||
return Password; | ||
} | ||
|
||
public String getPhoneNumber() { | ||
return 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.asu.librarysystem; | ||
|
||
public class Admin extends Account { | ||
|
||
public Admin( String adminName, String Password, String PhoneNumber) { | ||
super( adminName, Password, PhoneNumber); | ||
} | ||
|
||
public void manageBooksAvailablePurchase (){ | ||
|
||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
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; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import java.lang.String?> | ||
<?import javafx.geometry.Insets?> | ||
<?import javafx.scene.Cursor?> | ||
<?import javafx.scene.control.Button?> | ||
<?import javafx.scene.control.Label?> | ||
<?import javafx.scene.control.TableColumn?> | ||
<?import javafx.scene.control.TableView?> | ||
<?import javafx.scene.layout.AnchorPane?> | ||
<?import javafx.scene.layout.ColumnConstraints?> | ||
<?import javafx.scene.layout.GridPane?> | ||
<?import javafx.scene.layout.Pane?> | ||
<?import javafx.scene.layout.RowConstraints?> | ||
<?import javafx.scene.text.Font?> | ||
|
||
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="720.0" prefWidth="1280.0" styleClass="color1" stylesheets="@css/Style.css" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.asu.librarysystem.CRUD_Borrower_Controller"> | ||
<children> | ||
<TableView fx:id="borrowersTable" editable="true" layoutY="100.0" prefHeight="620.0" prefWidth="900.0" stylesheets="@css/Style.css"> | ||
<columns> | ||
<TableColumn fx:id="idcolumn" prefWidth="173.0" style="-fx-background-color: #EEEEEE; -fx-font-size: 20;" text="ID" /> | ||
<TableColumn fx:id="borrowerName" prefWidth="270.0" style="-fx-background-color: #00ADB5; -fx-font-size: 20;" text="Name" /> | ||
<TableColumn fx:id="borrowerPhoneNumber" prefWidth="250.0" style="-fx-background-color: #EEEEEE; -fx-font-size: 20;" text="PhoneNumber" /> | ||
<TableColumn fx:id="borrowerNumberofBooks" minWidth="7.0" prefWidth="206.0" style="-fx-background-color: #00ADB5; -fx-font-size: 20;" text="Number of Books" /> | ||
</columns> | ||
<styleClass> | ||
<String fx:value="color2" /> | ||
<String fx:value="CEN" /> | ||
</styleClass> | ||
<columnResizePolicy> | ||
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY" /> | ||
</columnResizePolicy> | ||
</TableView> | ||
<GridPane layoutX="901.0" layoutY="100.0" prefHeight="620.0" prefWidth="375.0"> | ||
<columnConstraints> | ||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> | ||
</columnConstraints> | ||
<rowConstraints> | ||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> | ||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> | ||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> | ||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> | ||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> | ||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> | ||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> | ||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> | ||
</rowConstraints> | ||
<children> | ||
<Button fx:id="deleteButton" minHeight="50.0" mnemonicParsing="false" onAction="#switch_To_Delete_view" prefHeight="81.0" prefWidth="380.0" styleClass="color2" stylesheets="@css/Style.css" text="Delete" textFill="#00adb5" GridPane.rowIndex="2"> | ||
<font> | ||
<Font name="Monospaced Regular" size="40.0" /> | ||
</font> | ||
<cursor> | ||
<Cursor fx:constant="HAND" /> | ||
</cursor> | ||
</Button> | ||
<Button fx:id="addButton" minHeight="50.0" mnemonicParsing="false" onAction="#switch_To_Signup" prefHeight="81.0" prefWidth="375.0" styleClass="color2" stylesheets="@css/Style.css" text="ADD" textFill="#00adb5"> | ||
<font> | ||
<Font name="Monospaced Regular" size="40.0" /> | ||
</font> | ||
<cursor> | ||
<Cursor fx:constant="HAND" /> | ||
</cursor> | ||
</Button> | ||
<Button fx:id="updateButton" minHeight="50.0" mnemonicParsing="false" onAction="#switch_To_Update_view" prefHeight="81.0" prefWidth="380.0" styleClass="color2" stylesheets="@css/Style.css" text="Update" textFill="#00adb5" GridPane.rowIndex="4"> | ||
<font> | ||
<Font name="Monospaced Regular" size="40.0" /> | ||
</font> | ||
<cursor> | ||
<Cursor fx:constant="HAND" /> | ||
</cursor> | ||
</Button> | ||
<Button fx:id="backButton" minHeight="50.0" mnemonicParsing="false" onAction="#switch_To_Main" prefHeight="81.0" prefWidth="380.0" styleClass="color2" stylesheets="@css/Style.css" text="Back" textFill="#00adb5" GridPane.rowIndex="6"> | ||
<font> | ||
<Font name="Monospaced Regular" size="40.0" /> | ||
</font> | ||
<cursor> | ||
<Cursor fx:constant="HAND" /> | ||
</cursor> | ||
</Button> | ||
<Pane prefHeight="200.0" prefWidth="200.0" styleClass="color1" stylesheets="@css/Style.css" GridPane.rowIndex="1" /> | ||
<Pane prefHeight="200.0" prefWidth="200.0" styleClass="color1" stylesheets="@css/Style.css" GridPane.rowIndex="3" /> | ||
<Pane prefHeight="200.0" prefWidth="200.0" styleClass="color1" stylesheets="@css/Style.css" GridPane.rowIndex="5" /> | ||
<Pane prefHeight="200.0" prefWidth="200.0" styleClass="color1" stylesheets="@css/Style.css" GridPane.rowIndex="7" /> | ||
</children> | ||
</GridPane> | ||
<AnchorPane prefHeight="99.0" prefWidth="1280.0" styleClass="color1" stylesheets="@css/Style.css"> | ||
<children> | ||
<Label layoutX="53.0" layoutY="20.0" text="Borrowers" textFill="#00adb5"> | ||
<font> | ||
<Font size="40.0" /> | ||
</font> | ||
<padding> | ||
<Insets left="500.0" /> | ||
</padding> | ||
</Label> | ||
</children> | ||
</AnchorPane> | ||
</children> | ||
</AnchorPane> |
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 |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package com.asu.librarysystem; | ||
|
||
import javafx.collections.FXCollections; | ||
import javafx.collections.ObservableList; | ||
import javafx.event.ActionEvent; | ||
import javafx.fxml.FXML; | ||
import javafx.fxml.FXMLLoader; | ||
import javafx.fxml.Initializable; | ||
import javafx.scene.Node; | ||
import javafx.scene.Parent; | ||
import javafx.scene.Scene; | ||
import javafx.scene.control.Button; | ||
import javafx.scene.control.TableColumn; | ||
import javafx.scene.control.TableView; | ||
import javafx.scene.control.cell.PropertyValueFactory; | ||
import javafx.stage.Stage; | ||
|
||
import java.io.IOException; | ||
import java.net.URL; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.Properties; | ||
import java.util.ResourceBundle; | ||
|
||
import static com.asu.librarysystem.Library.copyElementOfArrayList; | ||
|
||
public class CRUD_Borrower_Controller implements Initializable { | ||
@FXML | ||
private TableColumn<Borrower, String> borrowerName; | ||
@FXML | ||
private TableView<Borrower> borrowersTable; | ||
@FXML | ||
private TableColumn<Borrower, Integer> idcolumn; | ||
@FXML | ||
private TableColumn<Borrower, String> borrowerPhoneNumber; | ||
@FXML | ||
private TableColumn<Borrower, Integer> borrowerNumberofBooks; | ||
@FXML | ||
private Button deleteButton; | ||
@FXML | ||
private Button addButton; | ||
@FXML | ||
private Button updateButton; | ||
@FXML | ||
private Button backButton; | ||
|
||
Stage stage; | ||
Parent root; | ||
Scene scene; | ||
|
||
public Scene checkScenes = null; | ||
public Parent roots; | ||
|
||
public void scene(ActionEvent event, String Link) throws IOException { | ||
root = FXMLLoader.load(getClass().getResource(Link)); | ||
stage = (Stage) ((Node) event.getSource()).getScene().getWindow(); | ||
scene = new Scene(root); | ||
stage.setScene(scene); | ||
} | ||
|
||
public void switch_To_Signup(ActionEvent event) throws IOException { | ||
|
||
scene(event, "SIGNup.fxml"); | ||
// cameFromCRUD.setAdmin(true); | ||
|
||
// FXMLLoader loader = new FXMLLoader(getClass().getResource("CRUD_Borrower-view.fxml")); | ||
// roots = loader.load(); | ||
//// SignupController Sign = loader.getController(); | ||
// stage = (Stage) ((Node) event.getSource()).getScene().getWindow(); | ||
|
||
} | ||
|
||
public void switch_To_Main(ActionEvent event) throws IOException { | ||
scene(event, "Update.fxml");//Admin Main fxml file | ||
} | ||
|
||
public void switch_To_Delete_view(ActionEvent event) throws IOException { | ||
scene(event, "Delete-view.fxml"); | ||
} | ||
|
||
public void switch_To_Update_view(ActionEvent event) throws IOException { | ||
scene(event, "Update.fxml"); | ||
// return | ||
} | ||
|
||
ObservableList<Borrower> List = FXCollections.observableArrayList(Library.borrowers); | ||
|
||
@Override | ||
public void initialize(URL url, ResourceBundle resourceBundle) { | ||
idcolumn.setCellValueFactory(new PropertyValueFactory<Borrower, Integer>("id")); | ||
borrowerName.setCellValueFactory(new PropertyValueFactory<Borrower, String>("userName")); | ||
borrowerNumberofBooks.setCellValueFactory(new PropertyValueFactory<Borrower, Integer>("noOfBooks")); | ||
borrowerPhoneNumber.setCellValueFactory(new PropertyValueFactory<Borrower, String>("phoneNumber")); | ||
System.out.println(Library.borrowers); | ||
// List.addAll(Arrays.asList(Library.borrowers)); | ||
borrowersTable.setItems(List); | ||
} | ||
} |
Oops, something went wrong.