From d625bc37ddff62a0d1d64ba4d914725e49dc1738 Mon Sep 17 00:00:00 2001 From: James Kollilon Barclay III Date: Wed, 18 Feb 2026 17:00:58 -0500 Subject: [PATCH 1/3] "Finished customer class" --- .../java/org/codedifferently/Customer.java | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 src/main/java/org/codedifferently/Customer.java diff --git a/src/main/java/org/codedifferently/Customer.java b/src/main/java/org/codedifferently/Customer.java new file mode 100644 index 0000000..cdd8929 --- /dev/null +++ b/src/main/java/org/codedifferently/Customer.java @@ -0,0 +1,66 @@ +package org.codedifferently; + +public class Customer { + + private String name; + private String phoneNumber; + private int drinksPurchased; + + // Constructor + public Customer(String name, String phoneNumber, int drinksPurchased) { + this.name = name; + this.phoneNumber = phoneNumber; + this.drinksPurchased = drinksPurchased; + } + + // Getters + public String getName() { + return name; + } + + public String getPhoneNumber() { + return phoneNumber; + } + + public int getDrinksPurchased() { + return drinksPurchased; + } + + // Setters + public void setName(String name) { + this.name = name; + } + + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + } + + public void setDrinksPurchased(int drinksPurchased) { + this.drinksPurchased = drinksPurchased; + } + + // Add one drink to rewards counter + public void incrementDrinks() { + drinksPurchased = drinksPurchased + 1; + } + + // Check if customer has reward (5 drinks) + public boolean hasReward() { + if (drinksPurchased >= 5) { + return true; + } else { + return false; + } + } + + // Redeem reward (reset count) + public void redeemReward() { + drinksPurchased = 0; + } + + public String getCustomerInfo() { + return "Name: " + name + + "\nPhone Number: " + phoneNumber + + "\nDrinks Purchased: " + drinksPurchased; + } +} From 347e1d2d72ad418e42a56e8b0dfce9fb71e4ff92 Mon Sep 17 00:00:00 2001 From: James Kollilon Barclay III Date: Wed, 18 Feb 2026 17:05:01 -0500 Subject: [PATCH 2/3] "Checked to see if it ran" --- .../java/org/codedifferently/CoffeeItem.java | 32 +++++ src/main/java/org/codedifferently/Main.java | 116 ++++++++++++++++-- 2 files changed, 137 insertions(+), 11 deletions(-) create mode 100644 src/main/java/org/codedifferently/CoffeeItem.java diff --git a/src/main/java/org/codedifferently/CoffeeItem.java b/src/main/java/org/codedifferently/CoffeeItem.java new file mode 100644 index 0000000..ac6faea --- /dev/null +++ b/src/main/java/org/codedifferently/CoffeeItem.java @@ -0,0 +1,32 @@ +package org.codedifferently; + +public class CoffeeItem { + + private String name; + private double price; + + // Constructor + public CoffeeItem(String name, double price) { + this.name = name; + this.price = price; + } + + // Getters + public String getName() { + return name; + } + + public double getPrice() { + return price; + } + + // Setters + public void setName(String name) { + this.name = name; + } + + public void setPrice(double price) { + this.price = price; + } + +} diff --git a/src/main/java/org/codedifferently/Main.java b/src/main/java/org/codedifferently/Main.java index 435139b..a385add 100644 --- a/src/main/java/org/codedifferently/Main.java +++ b/src/main/java/org/codedifferently/Main.java @@ -1,17 +1,111 @@ package org.codedifferently; -//TIP To Run code, press or -// click the icon in the gutter. +import java.util.Scanner; + 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); + + Scanner scanner = new Scanner(System.in); + + // Create drinks + CoffeeItem latte = new CoffeeItem("Latte", 4.50); + CoffeeItem espresso = new CoffeeItem("Espresso", 3.00); + CoffeeItem cappuccino = new CoffeeItem("Cappuccino", 5.00); + + System.out.println("Welcome to Triple C's!"); + + boolean shopOpen = true; + + while (shopOpen) { + + System.out.println("\nEnter customer name:"); + String name = scanner.nextLine(); + + System.out.println("Enter customer email:"); + String email = scanner.nextLine(); + + Customer customer = new Customer(name, email, 0); + + System.out.println("\nMenu:"); + System.out.println("1. Latte"); + System.out.println("2. Espresso"); + System.out.println("3. Cappuccino"); + System.out.println("4. Close Shop"); + + int choice = scanner.nextInt(); + + if (choice == 4) { + shopOpen = false; + break; + } + + CoffeeItem selectedDrink = null; + + if (choice == 1) { + selectedDrink = latte; + } else if (choice == 2) { + selectedDrink = espresso; + } else if (choice == 3) { + selectedDrink = cappuccino; + } else { + System.out.println("Invalid choice."); + scanner.nextLine(); // clear + continue; + } + + System.out.println("How many would you like?"); + int quantity = scanner.nextInt(); + scanner.nextLine(); // clear buffer + + if (quantity <= 0) { + System.out.println("Invalid quantity."); + continue; + } + + double total = selectedDrink.getPrice() * quantity; + + System.out.println("\nCustomer: " + customer.getName()); + System.out.println("Drinks toward reward: " + customer.getDrinksPurchased()); + System.out.println("========================="); + + // Reward check + if (customer.hasReward()) { + + System.out.println("CONGRATS! Reward reached. Next drink is free!"); + customer.redeemReward(); + System.out.println("========================="); + } else { + + System.out.println(customer.getName() + " purchased " + + quantity + " " + selectedDrink.getName() + + "(s) for $" + total); + + // add drinks to reward counter + for (int i = 0; i < quantity; i++) { + customer.incrementDrinks(); + } + } + + // Golden Ticket + if (total > 20) { + System.out.println("Golden Ticket! You earned a bonus drink point!"); + customer.incrementDrinks(); + System.out.println("========================="); + } + + System.out.println("Updated drinks toward reward: " + + customer.getDrinksPurchased()); + System.out.println("========================="); + System.out.println("\nNext customer? (yes/no)"); + String answer = scanner.nextLine(); + System.out.println("========================="); + if (answer.equalsIgnoreCase("no")) { + shopOpen = false; + } } + + System.out.println("Shop Closed!"); + scanner.close(); } -} \ No newline at end of file +} From 4517cdc8826031f010702a3990a58455a3dc5434 Mon Sep 17 00:00:00 2001 From: James Kollilon Barclay III Date: Wed, 18 Feb 2026 17:07:09 -0500 Subject: [PATCH 3/3] Added barclay push --- .idea/encodings.xml | 7 +++++++ .idea/misc.xml | 10 +++++++++- .idea/vcs.xml | 6 ++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 .idea/encodings.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..aa00ffa --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 4b151ab..b08581c 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,14 @@ - + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file