Finalized the project

This commit is contained in:
Sage The DM 2025-01-13 21:26:26 +01:00
parent fa36d02929
commit 772f952ea3
3 changed files with 25 additions and 11 deletions

View file

@ -0,0 +1,6 @@
Lord of the Rings
Lord of the Rings
Lord of the Rings
Lord of the Rings
The Wheel of Time
The Wheel of Time

View file

@ -57,49 +57,57 @@ public class ShopController {
// Book Addition Handlers
@FXML
private void handleAddToCartButton1(ActionEvent event) {
addToCart("Lord of the Rings");
addToCart("Lord of the Rings",
"A high-fantasy epic by J.R.R. Tolkien. The story follows the journey of Frodo Baggins and his companions as they attempt to destroy the One Ring and defeat the Dark Lord Sauron.");
}
@FXML
private void handleAddToCartButton2(ActionEvent event) {
addToCart("The Wheel of Time");
addToCart("The Wheel of Time",
"A sprawling epic fantasy series by Robert Jordan. It follows the journey of Rand al'Thor as he struggles to control his newfound powers and faces the ultimate battle between light and shadow.");
}
@FXML
private void handleAddToCartButton3(ActionEvent event) {
addToCart("The Chronicles of Narnia");
addToCart("The Chronicles of Narnia",
"A beloved fantasy series by C.S. Lewis. It tells the magical adventures of children in the land of Narnia, filled with mythical creatures, epic battles, and profound allegorical themes.");
}
@FXML
private void handleAddToCartButton4(ActionEvent event) {
addToCart("The Earthsea Cycle");
addToCart("The Earthsea Cycle",
"A fantasy series by Ursula K. Le Guin. It explores the coming-of-age journey of Ged, a young wizard, as he navigates the balance of power, magic, and morality.");
}
@FXML
private void handleAddToCartButton5(ActionEvent event) {
addToCart("The First Law Trilogy");
addToCart("The First Law Trilogy",
"A grimdark fantasy series by Joe Abercrombie. It features morally complex characters, brutal realism, and intertwining stories of politics, war, and betrayal.");
}
@FXML
private void handleAddToCartButton6(ActionEvent event) {
addToCart("The Kingkiller Chronicle");
addToCart("The Kingkiller Chronicle",
"An epic fantasy series by Patrick Rothfuss. It recounts the life of Kvothe, a gifted musician and magician, as he seeks revenge and unravels mysteries in a richly imagined world.");
}
@FXML
private void handleAddToCartButton7(ActionEvent event) {
addToCart("The Mistborn Series");
addToCart("The Mistborn Series",
"A unique fantasy series by Brandon Sanderson. It combines a rich magic system based on metals with a story of rebellion, heroism, and unexpected twists.");
}
@FXML
private void handleAddToCartButton8(ActionEvent event) {
addToCart("The Stormlight Archive");
addToCart("The Stormlight Archive",
"A grand fantasy epic by Brandon Sanderson. It weaves together multiple characters' stories in a richly detailed world of war, magic, and ancient secrets.");
}
private void addToCart(String bookTitle) {
private void addToCart(String bookTitle, String bookDescription) {
try (BufferedWriter writer = new BufferedWriter(new FileWriter(CART_FILE, true))) {
writer.write(bookTitle);
writer.write(bookTitle + " - " + bookDescription);
writer.newLine();
System.out.println("Added to cart: " + bookTitle);
System.out.println("Added to cart: " + bookTitle + " with description: " + bookDescription);
} catch (IOException e) {
System.err.println("Failed to add item to cart: " + e.getMessage());
}