diff --git a/src/main/java/org/codedifferently/CoreyScottCoffeeShopApp.java b/src/main/java/org/codedifferently/CoreyScottCoffeeShopApp.java new file mode 100644 index 0000000..beab122 --- /dev/null +++ b/src/main/java/org/codedifferently/CoreyScottCoffeeShopApp.java @@ -0,0 +1,72 @@ +package org.codedifferently; + +import java.util.Scanner; + +public class CoreyScottCoffeeShopApp { + + public static void main(String[] args) { + + CoreyScottCoffeeShopSystem system = + new CoreyScottCoffeeShopSystem(); + + Scanner scanner = new Scanner(System.in); + int choice; + + do { + System.out.println("\n=== Coffee Shop System ==="); + System.out.println("1. Schedule Order"); + System.out.println("2. View Schedule"); + System.out.println("3. Complete Order"); + System.out.println("4. Daily Report"); + System.out.println("0. Exit"); + System.out.print("Choose: "); + + choice = scanner.nextInt(); + scanner.nextLine(); + + switch (choice) { + + case 1: + System.out.print("Customer name: "); + String name = scanner.nextLine(); + + System.out.print("Drink: "); + String drink = scanner.nextLine(); + + System.out.print("Slot (0-5): "); + int slot = scanner.nextInt(); + scanner.nextLine(); + + system.scheduleOrder(name, slot, drink); + break; + + case 2: + system.viewSchedule(); + break; + + case 3: + System.out.print("Slot to complete: "); + int completeSlot = scanner.nextInt(); + scanner.nextLine(); + + system.completeOrder(completeSlot); + break; + + case 4: + system.dailyReport(); + break; + + case 0: + System.out.println("Goodbye!"); + break; + + default: + System.out.println("Invalid choice."); + } + + } while (choice != 0); + + scanner.close(); + } +} + diff --git a/src/main/java/org/codedifferently/CoreyScottCoffeeShopSystem.java b/src/main/java/org/codedifferently/CoreyScottCoffeeShopSystem.java new file mode 100644 index 0000000..30b65c8 --- /dev/null +++ b/src/main/java/org/codedifferently/CoreyScottCoffeeShopSystem.java @@ -0,0 +1,94 @@ +package org.codedifferently; + +import java.util.ArrayList; + +public class CoreyScottCoffeeShopSystem { + + private ArrayList orders; + private ArrayList waitlist; + private String[] pickupSlots; + + public CoreyScottCoffeeShopSystem() { + orders = new ArrayList<>(); + waitlist = new ArrayList<>(); + + pickupSlots = new String[]{ + "8am", "9am", "10am", "11am", "12pm", "2pm" + }; + } + + public void viewSchedule() { + for (int i = 0; i < pickupSlots.length; i++) { + + boolean booked = false; + + for (CoreyScottOrder order : orders) { + if (order.getPickupSlot() == i) { + System.out.println(pickupSlots[i] + " - " + order); + booked = true; + break; + } + } + + if (!booked) { + System.out.println(pickupSlots[i] + " - Available"); + } + } + } + + public void scheduleOrder(String customer, int slot, String drink) { + + if (slot < 0 || slot >= pickupSlots.length) { + System.out.println("Invalid slot!"); + return; + } + + for (CoreyScottOrder order : orders) { + if (order.getPickupSlot() == slot) { + System.out.println("Slot full — added to waitlist."); + waitlist.add(customer); + return; + } + } + + orders.add(new CoreyScottOrder(customer, slot, drink)); + System.out.println("Order scheduled!"); + } + + public void completeOrder(int slot) { + + for (CoreyScottOrder order : orders) { + + if (order.getPickupSlot() == slot) { + + if (order.isCompleted()) { + System.out.println("Already completed!"); + return; + } + + order.markCompleted(); + System.out.println("Order completed!"); + return; + } + } + + System.out.println("No order found."); + } + + public void dailyReport() { + + int completed = 0; + + for (CoreyScottOrder order : orders) { + if (order.isCompleted()) { + completed++; + } + } + + System.out.println("\n--- Daily Coffee Shop Report ---"); + System.out.println("Total orders: " + orders.size()); + System.out.println("Completed orders: " + completed); + System.out.println("Pending orders: " + (orders.size() - completed)); + System.out.println("Waitlist size: " + waitlist.size()); + } +} \ No newline at end of file diff --git a/src/main/java/org/codedifferently/CoreyScottOrder.java b/src/main/java/org/codedifferently/CoreyScottOrder.java new file mode 100644 index 0000000..9f86ccb --- /dev/null +++ b/src/main/java/org/codedifferently/CoreyScottOrder.java @@ -0,0 +1,37 @@ +package org.codedifferently; + +public class CoreyScottOrder { + + private String customer; + private int pickupSlot; + private boolean completed; + private String drink; + + public CoreyScottOrder(String customer, int pickupSlot, String drink) { + this.customer = customer; + this.pickupSlot = pickupSlot; + this.drink = drink; + this.completed = false; + } + + public int getPickupSlot() { + return pickupSlot; + } + + public boolean isCompleted() { + return completed; + } + + public void markCompleted() { + completed = true; + } + + @Override + public String toString() { + String status = completed ? "Order Ready" : "Preparing Order"; + return "Slot: " + pickupSlot + + " | " + drink + + " for " + customer + + " | " + status; + } +} \ No newline at end of file diff --git a/src/main/java/org/codedifferently/Customer.java b/src/main/java/org/codedifferently/Customer.java new file mode 100644 index 0000000..4572e51 --- /dev/null +++ b/src/main/java/org/codedifferently/Customer.java @@ -0,0 +1,38 @@ +package org.codedifferently; + +public class Customer { + + private static int nextId = 1; + + private int id; + private String name; + private boolean checkedIn; + + public Customer(String name) { + this.id = nextId++; + this.name = name; + this.checkedIn = false; + } + + public int getId() { + return id; + } + + public String getName() { + return name; + } + + public boolean isCheckedIn() { + return checkedIn; + } + + public void checkIn() { + checkedIn = true; + } + + @Override + public String toString() { + String status = checkedIn ? "Checked In" : "Not Checked In"; + return "ID: " + id + " | Name: " + name + " | " + status; + } +} \ No newline at end of file diff --git a/src/main/java/org/codedifferently/Main.java b/src/main/java/org/codedifferently/Main.java deleted file mode 100644 index 435139b..0000000 --- a/src/main/java/org/codedifferently/Main.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.codedifferently; - -//TIP To Run code, press or -// click the icon in the gutter. -public class Main { - public static void main(String[] args) { - //TIP Press with your caret at the highlighted text - // to see how IntelliJ IDEA suggests fixing it. - System.out.printf("Hello and welcome!"); - - for (int i = 1; i <= 5; i++) { - //TIP Press to start debugging your code. We have set one breakpoint - // for you, but you can always add more by pressing . - System.out.println("i = " + i); - } - } -} \ No newline at end of file