final version

This commit is contained in:
Sage The DM 2025-01-13 21:34:30 +01:00
parent 772f952ea3
commit f25a51dd1c
3 changed files with 6 additions and 8 deletions

View file

@ -1,6 +0,0 @@
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

@ -67,8 +67,12 @@ public class CartController {
try (BufferedReader reader = new BufferedReader(new FileReader(CART_FILE))) { try (BufferedReader reader = new BufferedReader(new FileReader(CART_FILE))) {
String line; String line;
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {
// Assuming each line contains only the book name for simplicity String[] parts = line.split(" - ", 2);
cartItems.add(new Item(line, "Book Description", 1, 9.99)); if (parts.length == 2) {
String name = parts[0].trim();
String description = parts[1].trim();
cartItems.add(new Item(name, description, 1, 9.99));
}
} }
} catch (IOException e) { } catch (IOException e) {
System.err.println("Error loading cart items: " + e.getMessage()); System.err.println("Error loading cart items: " + e.getMessage());