Skip to content
72 changes: 72 additions & 0 deletions src/main/java/org/codedifferently/CoreyScottCoffeeShopApp.java
Original file line number Diff line number Diff line change
@@ -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();
}
}

94 changes: 94 additions & 0 deletions src/main/java/org/codedifferently/CoreyScottCoffeeShopSystem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package org.codedifferently;

import java.util.ArrayList;

public class CoreyScottCoffeeShopSystem {

private ArrayList<CoreyScottOrder> orders;
private ArrayList<String> 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());
}
}
37 changes: 37 additions & 0 deletions src/main/java/org/codedifferently/CoreyScottOrder.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
38 changes: 38 additions & 0 deletions src/main/java/org/codedifferently/Customer.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
17 changes: 0 additions & 17 deletions src/main/java/org/codedifferently/Main.java

This file was deleted.