Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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

import java.util.Scanner;

public class CoffeeCafeApp {


public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

// 🔹 Create 6 Customers
Customer c1 = new Customer("Chris", "chris@gmail.com", 120);
Customer c2 = new Customer("Derwin", "derwin@yahoo.com", 40);
Customer c3 = new Customer("Henrietta", "henrietta@gmail.com", 260);
Customer c4 = new Customer("Mason", "mason@gmail.com", 80);
Customer c5 = new Customer("Jayden", "jayden@gmail.com", 310);
Customer c6 = new Customer("Brian", "brian@yahoo.com", 10);

// Menu Items
Purchase coffee = new Purchase("Coffee", 4.50, true);
Purchase latte = new Purchase("Latte", 5.50, true);
Purchase cappuccino = new Purchase("Cappuccino", 6.00, true);
Purchase muffin = new Purchase("Muffin", 3.25, false);
Purchase croissant = new Purchase("Croissant", 3.75, false);
Purchase sandwich = new Purchase("Sandwich", 8.50, false);

System.out.println("☕ Welcome to Triple C’s");
System.out.println("Coffee. Code. Consistency.");
System.out.println("--------------------------");

// Select Customer
System.out.println("Select Customer:");
System.out.println("1) Chris");
System.out.println("2) Derwin");
System.out.println("3) Henrietta");
System.out.println("4) Mason");
System.out.println("5) Jayden");
System.out.println("6) Brian");

int choice;

while (true) {
if (!sc.hasNextInt()) {
System.out.println("Invalid input. Please enter a number.");
sc.next();
continue;
}

choice = sc.nextInt();
sc.nextLine();
break;
}

Customer current;

if (choice == 1) current = c1;
else if (choice == 2) current = c2;
else if (choice == 3) current = c3;
else if (choice == 4) current = c4;
else if (choice == 5) current = c5;
else current = c6;

double purchasedTotal = 0;
int purchasedPoints = 0;
String allPurchasedItems = " ";

while (true) {

System.out.println("\n----- MENU -----");
System.out.println("1) Coffee - $4.50");
System.out.println("2) Latte - $5.50");
System.out.println("3) Cappuccino - $6.00");
System.out.println("4) Muffin - $3.25");
System.out.println("5) Croissant - $3.75");
System.out.println("6) Sandwich - $8.50");
System.out.println("7) Finish Order");

int itemChoice;

while (true) {
if (!sc.hasNextInt()) {
System.out.println("Invalid input. Please enter a number from the menu.");
sc.next();
continue;
}

itemChoice = sc.nextInt();
break;
}

if (itemChoice == 7) break;

Purchase selected = null;

if (itemChoice == 1) selected = coffee;
else if (itemChoice == 2) selected = latte;
else if (itemChoice == 3) selected = cappuccino;
else if (itemChoice == 4) selected = muffin;
else if (itemChoice == 5) selected = croissant;
else if (itemChoice == 6) selected = sandwich;
else {
System.out.println("Invalid choice.");
continue;
}

// print out purchased items & price
allPurchasedItems += selected.getItemName()
+ " $" + selected.getPrice()
+ "\n";

purchasedTotal += selected.getPrice();

int earned = (int) selected.getPrice(); // $1 = 1 point
purchasedPoints += (int) earned;

System.out.println("Purchased Items: " + selected.getItemName() +
" | $" + selected.getPrice());

}

System.out.println("\n========= Welcome to Triple Cs!=========");
System.out.println("Customer: " + current.getName());
System.out.println("Purchased Items: " + "\n" + allPurchasedItems);
System.out.println("Total: $" + purchasedTotal);
System.out.println("Points toward reward: " + purchasedPoints);
System.out.println("Total Points: " + current.getPoints());
System.out.println("Tier Status: " + current.getTier());
System.out.println("============================");

// Redemption
System.out.println("Redeem Free Drink (100 points)? (y/n)");
sc.nextLine();
String redeem = sc.nextLine();

if (redeem.equalsIgnoreCase("y")) {
current.redeemReward();
}

System.out.println("\nFinal Status:");
System.out.println(current.getName() + " | "
+ current.getTier() + " | "
+ current.getPoints() + " points");

sc.close();
}
}


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

public class Customer {


private String name;
private String email;
private int points;

// Default Constructor
public Customer() {
this.name = "Guest";
this.email = "N/A";
this.points = 0;
}

// Parameterized Constructor
public Customer(String name, String email, int points) {
this.name = name;
this.email = email;
this.points = points;
}

// Getters & Setters
public String getName() { return name; }
public String getPhoneNumber() { return email; }
public int getPoints() { return points; }

public void setName(String name) { this.name = name; }
public void setPhoneNumber(String phoneNumber) { this.email = phoneNumber; }
public void setPoints(int points) { this.points = points; }



// Add points
public void addPoints(int earned) {
this.points += earned;
}


// Redeem reward
//Create a method to check if the customer is eligible for a Reward
// (e.g., if they have bought 5 drinks, the next one is free).
public void redeemReward() {
if (points >= 100) {
points -= 100;
System.out.println(" Free Drink Redeemed!");
} else {
System.out.println(" Not enough points for reward.");
}
}

// Tier System
public String getTier() {
if (points >= 300) return "Gold";
else if (points >= 150) return "Silver";
else return "Bronze";
}
}
11 changes: 1 addition & 10 deletions src/main/java/org/codedifferently/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,6 @@
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
public class Main {
public static void main(String[] args) {
//TIP Press <shortcut actionId="ShowIntentionActions"/> 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 <shortcut actionId="Debug"/> to start debugging your code. We have set one <icon src="AllIcons.Debugger.Db_set_breakpoint"/> breakpoint
// for you, but you can always add more by pressing <shortcut actionId="ToggleLineBreakpoint"/>.
System.out.println("i = " + i);
}
}

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


public class Purchase {

private String itemName;
private double price;
private boolean isDrink;

public Purchase(String itemName, double price, boolean isDrink) {
this.itemName = itemName;
this.price = price;
this.isDrink = isDrink;
}



public String getItemName() { return itemName; }
public double getPrice() { return price; }
public boolean isDrink() { return isDrink; }
}