diff --git a/Code/ost/JAVA-FX-PROJECT/_javafx_website_task/cart.txt b/Code/ost/JAVA-FX-PROJECT/_javafx_website_task/cart.txt index fea1ebb..e69de29 100644 --- a/Code/ost/JAVA-FX-PROJECT/_javafx_website_task/cart.txt +++ b/Code/ost/JAVA-FX-PROJECT/_javafx_website_task/cart.txt @@ -1,19 +0,0 @@ -The Earthsea Cycle -The Chronicles of Narnia -The Mistborn Series -The Earthsea Cycle -The Kingkiller Chronicle -The Kingkiller Chronicle -The Kingkiller Chronicle -The Kingkiller Chronicle -The Kingkiller Chronicle -The Kingkiller Chronicle -The Kingkiller Chronicle -The Kingkiller Chronicle -The Kingkiller Chronicle -The Kingkiller Chronicle -The Kingkiller Chronicle -The Kingkiller Chronicle -The Kingkiller Chronicle -The Kingkiller Chronicle -The Wheel of Time diff --git a/Code/ost/JAVA-FX-PROJECT/_javafx_website_task/src/main/java/com/example/CartController.java b/Code/ost/JAVA-FX-PROJECT/_javafx_website_task/src/main/java/com/example/CartController.java index 34965c2..8785177 100644 --- a/Code/ost/JAVA-FX-PROJECT/_javafx_website_task/src/main/java/com/example/CartController.java +++ b/Code/ost/JAVA-FX-PROJECT/_javafx_website_task/src/main/java/com/example/CartController.java @@ -76,12 +76,12 @@ public class CartController { } @FXML - private void handleCartButton() throws IOException { + private void handleCartButton(ActionEvent event) throws IOException { App.setRoot("cart"); } @FXML - private void handleLoginButton() throws IOException { + private void handleLoginButton(ActionEvent event) throws IOException { App.setRoot("login"); } diff --git a/Code/ost/JAVA-FX-PROJECT/_javafx_website_task/src/main/java/com/example/CheckOutController.java b/Code/ost/JAVA-FX-PROJECT/_javafx_website_task/src/main/java/com/example/CheckOutController.java index d68962c..cd189e5 100644 --- a/Code/ost/JAVA-FX-PROJECT/_javafx_website_task/src/main/java/com/example/CheckOutController.java +++ b/Code/ost/JAVA-FX-PROJECT/_javafx_website_task/src/main/java/com/example/CheckOutController.java @@ -1,10 +1,14 @@ package com.example; +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.FileWriter; import java.io.IOException; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.*; +import javafx.scene.control.Alert.AlertType; import javafx.scene.input.MouseEvent; public class CheckOutController { @@ -78,12 +82,12 @@ public class CheckOutController { } @FXML - private void handleCartButton() throws IOException { + private void handleCartButton(ActionEvent event) throws IOException { App.setRoot("cart"); } @FXML - private void handleLoginButton() throws IOException { + private void handleLoginButton(ActionEvent event) throws IOException { App.setRoot("login"); } @@ -109,12 +113,13 @@ public class CheckOutController { // Validate the input fields if (fullName.isEmpty() || address.isEmpty() || city.isEmpty() || zip.isEmpty() || cardNumber.isEmpty() - || cardHolderName.isEmpty() || expiryDate.isEmpty() || cvv.isEmpty()) { - System.out.println("Please fill out all fields."); + || cardHolderName.isEmpty() || expiryDate.isEmpty() || cvv.isEmpty() || country.isEmpty()) { + Alert alert = new Alert(AlertType.ERROR, "Please fill out all fields.", ButtonType.OK); + alert.showAndWait(); } else { - System.out.println("Form submitted successfully."); - System.out.printf("Billing Info: %s, %s, %s, %s, %s\n", fullName, address, city, zip, country); - System.out.printf("Credit Card Info: %s, %s, %s, CVV: %s\n", cardNumber, cardHolderName, expiryDate, cvv); + Alert alert = new Alert(AlertType.INFORMATION, "Form submitted successfully.", ButtonType.OK); + alert.showAndWait(); + FileWriter fileWriter = new FileWriter("cart.txt", false); App.setRoot("shop"); } } diff --git a/Code/ost/JAVA-FX-PROJECT/_javafx_website_task/src/main/java/com/example/LoginController.java b/Code/ost/JAVA-FX-PROJECT/_javafx_website_task/src/main/java/com/example/LoginController.java index 0665726..6188162 100644 --- a/Code/ost/JAVA-FX-PROJECT/_javafx_website_task/src/main/java/com/example/LoginController.java +++ b/Code/ost/JAVA-FX-PROJECT/_javafx_website_task/src/main/java/com/example/LoginController.java @@ -130,7 +130,7 @@ public class LoginController { } @FXML - private void handleCartButton() throws IOException { + private void handleCartButton(ActionEvent event) throws IOException { App.setRoot("cart"); } diff --git a/Code/ost/JAVA-FX-PROJECT/_javafx_website_task/src/main/java/com/example/RegisterController.java b/Code/ost/JAVA-FX-PROJECT/_javafx_website_task/src/main/java/com/example/RegisterController.java index dcee741..d736144 100644 --- a/Code/ost/JAVA-FX-PROJECT/_javafx_website_task/src/main/java/com/example/RegisterController.java +++ b/Code/ost/JAVA-FX-PROJECT/_javafx_website_task/src/main/java/com/example/RegisterController.java @@ -153,12 +153,12 @@ public class RegisterController { } @FXML - private void handleCartButton() throws IOException { + private void handleCartButton(ActionEvent event) throws IOException { App.setRoot("cart"); } @FXML - private void handleLoginButton() throws IOException { + private void handleLoginButton(ActionEvent event) throws IOException { App.setRoot("login"); } diff --git a/Code/ost/JAVA-FX-PROJECT/_javafx_website_task/src/main/java/com/example/ShopController.java b/Code/ost/JAVA-FX-PROJECT/_javafx_website_task/src/main/java/com/example/ShopController.java index fe027d2..5e61ac0 100644 --- a/Code/ost/JAVA-FX-PROJECT/_javafx_website_task/src/main/java/com/example/ShopController.java +++ b/Code/ost/JAVA-FX-PROJECT/_javafx_website_task/src/main/java/com/example/ShopController.java @@ -3,6 +3,8 @@ package com.example; import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException; + +import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.Button; import javafx.scene.control.Label; @@ -43,53 +45,53 @@ public class ShopController { } @FXML - private void handleCartButton() throws IOException { + private void handleCartButton(ActionEvent event) throws IOException { App.setRoot("cart"); } @FXML - private void handleLoginButton() throws IOException { + private void handleLoginButton(ActionEvent event) throws IOException { App.setRoot("login"); } // Book Addition Handlers @FXML - private void handleAddToCartButton1() { + private void handleAddToCartButton1(ActionEvent event) { addToCart("Lord of the Rings"); } @FXML - private void handleAddToCartButton2() { + private void handleAddToCartButton2(ActionEvent event) { addToCart("The Wheel of Time"); } @FXML - private void handleAddToCartButton3() { + private void handleAddToCartButton3(ActionEvent event) { addToCart("The Chronicles of Narnia"); } @FXML - private void handleAddToCartButton4() { + private void handleAddToCartButton4(ActionEvent event) { addToCart("The Earthsea Cycle"); } @FXML - private void handleAddToCartButton5() { + private void handleAddToCartButton5(ActionEvent event) { addToCart("The First Law Trilogy"); } @FXML - private void handleAddToCartButton6() { + private void handleAddToCartButton6(ActionEvent event) { addToCart("The Kingkiller Chronicle"); } @FXML - private void handleAddToCartButton7() { + private void handleAddToCartButton7(ActionEvent event) { addToCart("The Mistborn Series"); } @FXML - private void handleAddToCartButton8() { + private void handleAddToCartButton8(ActionEvent event) { addToCart("The Stormlight Archive"); } diff --git a/Code/ost/JAVA-FX-PROJECT/_javafx_website_task/src/main/resources/com/example/cart.fxml b/Code/ost/JAVA-FX-PROJECT/_javafx_website_task/src/main/resources/com/example/cart.fxml index 7f4980e..3ba2403 100644 --- a/Code/ost/JAVA-FX-PROJECT/_javafx_website_task/src/main/resources/com/example/cart.fxml +++ b/Code/ost/JAVA-FX-PROJECT/_javafx_website_task/src/main/resources/com/example/cart.fxml @@ -41,7 +41,7 @@ -