From 61eb0bf26747edc3ebc5333b342a65c85a1f9746 Mon Sep 17 00:00:00 2001 From: Derwin Bell Date: Mon, 16 Feb 2026 19:08:31 -0500 Subject: [PATCH 1/4] DONE Steps 1,2,3 --- .idea/encodings.xml | 7 + .idea/misc.xml | 10 +- .idea/vcs.xml | 6 + src/main/java/derwinbell/Customer.java | 41 +++++ src/main/java/derwinbell/Main.java | 158 ++++++++++++++++++++ src/main/java/derwinbell/Purchase.java | 40 +++++ src/main/java/org/codedifferently/Main.java | 17 --- 7 files changed, 261 insertions(+), 18 deletions(-) create mode 100644 .idea/encodings.xml create mode 100644 .idea/vcs.xml create mode 100644 src/main/java/derwinbell/Customer.java create mode 100644 src/main/java/derwinbell/Main.java create mode 100644 src/main/java/derwinbell/Purchase.java delete mode 100644 src/main/java/org/codedifferently/Main.java 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..efb1e13 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 diff --git a/src/main/java/derwinbell/Customer.java b/src/main/java/derwinbell/Customer.java new file mode 100644 index 0000000..eba64f7 --- /dev/null +++ b/src/main/java/derwinbell/Customer.java @@ -0,0 +1,41 @@ +package derwinbell; + +public class Customer { + + private String name; + + private String phoneNumber; + + private int points; + + public Customer(String name, String phoneNumber, int points){ + this.name = name; + this.phoneNumber = phoneNumber; + this.points = points; + + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPhoneNumber() { + return phoneNumber; + } + + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + } + + public int getPoints() { + return points; + } + + public void setPoints(int points) { + this.points = points; + } +} diff --git a/src/main/java/derwinbell/Main.java b/src/main/java/derwinbell/Main.java new file mode 100644 index 0000000..c538c49 --- /dev/null +++ b/src/main/java/derwinbell/Main.java @@ -0,0 +1,158 @@ +package derwinbell; + +import java.util.Scanner; + +//TIP To Run code, press or +// click the icon in the gutter. +public class Main { + + public static void menuApp(){ + Customer customer = new Customer("Derwin", "302-605-5552", 0); + Purchase purchase = new Purchase("", 0, true); + Scanner scan = new Scanner(System.in); + + String playAgain; + int points = 0; + String tier = "Bronze"; + + + + System.out.println("Whats your Name?"); + customer.setName(scan.nextLine()); + + System.out.println("Whats your phone number?"); + customer.setPhoneNumber(scan.nextLine()); + System.out.println("Your name is " + customer.getName() + "\nPhone Number: " + customer.getPhoneNumber() + "\nPoints: " + customer.getPoints()); + + + do { + playAgain = "n"; + + if(tier.equals("Bronze") && points >= 200) { + System.out.println("Hey nigga you want to go up a Tier? \nits 200 points to go up to SILVER (y/n)"); + String choice = scan.next(); + if(choice.equals("y")) { + System.out.println("Congrats nigga, you made it"); + tier = "Silver"; + points-=200; + scan.nextLine() ; + } + else if(choice.equals("n")) { + System.out.println("oh alright, broke ass nigga"); + scan.nextLine() ; + + } + } + else if (tier.equals("Silver") && points >= 400){ + System.out.println("Damn Big Back\n you keep coming back! \nits 400 points to go up to GOLD you want in? (y/n)"); + String choice = scan.next(); + if(choice.equals("y")) { + System.out.println("ofc your fat ass would"); + tier = "Gold"; + points-=400; + } + else if(choice.equals("n")) { + System.out.println("oh fasho, maybe you can invest in a gym membership then"); + + } + + } + + System.out.println("its 100 points for a free drink, do you want it? (y/n)"); + String freeDrink = scan.nextLine(); + + if(freeDrink.equals("y")) + { + if(points >= 100){ + System.out.println("Here's your free drink!"); + } + else { + System.out.println("nigga that's not enough"); + points-=100; + } + } + else if (freeDrink.equals("n")){ + System.out.println("Okay, what would you like today?"); + } + else { + System.out.println("Invalid"); + } + + + + System.out.println("Select item\n1. Ramen Noodles 5.00\n2. Sprite 2.00\n3. TV Dinner 15.00\n4. Chips 4.00\n5. Diet Coke 2.50\n6. Fruit 1.50"); + int userInput = scan.nextInt(); + + if(userInput > 8 || userInput < 1) { + System.out.println("invalid "); + continue; + } + + + + switch (userInput){ + case 1: + purchase.setItemName("Ramen Noodles"); + purchase.setPrice(5.94); + points += 90; + break; + + case 2: + purchase.setItemName("Sprite"); + purchase.setPrice(2.88); + points += 50; + break; + case 3: + purchase.setItemName("TV Dinner"); + purchase.setPrice(15.99); + points += 100; + break; + case 4: + purchase.setItemName("Chips"); + purchase.setPrice(4.23); + points += 60; + break; + case 5: + purchase.setItemName("Diet Coke"); + purchase.setPrice(2.59); + points += 50; + break; + case 6: + purchase.setItemName("Fruit"); + purchase.setPrice(1.52); + points += 20; + break; + } + customer.setPoints(points); + + System.out.println("You want " + purchase.getItemName() + " " + "it is $" + purchase.getPrice()); + System.out.println("You get " + customer.getPoints() + " points" ); + System.out.println(customer.getName() + "|" + tier + "|" + customer.getPoints()); + + while (true) { + System.out.print("is That all?? (y/n): "); + playAgain = scan.next().toLowerCase(); + + if (playAgain.equals("y") || playAgain.equals("n")) { + scan.nextLine() ; + break; + } + else { + System.out.println("Invalid input!"); + + } + } + + + }while(playAgain.equals("n")); + + + } + + + + public static void main(String[] args) { + menuApp(); + + } +} \ No newline at end of file diff --git a/src/main/java/derwinbell/Purchase.java b/src/main/java/derwinbell/Purchase.java new file mode 100644 index 0000000..06f95ee --- /dev/null +++ b/src/main/java/derwinbell/Purchase.java @@ -0,0 +1,40 @@ +package derwinbell; + +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 void setItemName(String itemName) { + this.itemName = itemName; + } + + public double getPrice() { + return price; + } + + public void setPrice(double price) { + this.price = price; + } + + public boolean getDrink() { + return isDrink; + } + + public void setDrink(boolean drink) { + isDrink = drink; + } +} 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 From 455b0599aeabb44738abd4e493c0cdde299e93f2 Mon Sep 17 00:00:00 2001 From: coreyeross25 Date: Tue, 17 Feb 2026 09:32:34 -0500 Subject: [PATCH 2/4] Update README.md --- README.md | 151 ++++++++++-------------------------------------------- 1 file changed, 28 insertions(+), 123 deletions(-) diff --git a/README.md b/README.md index 0111397..986abae 100644 --- a/README.md +++ b/README.md @@ -1,147 +1,52 @@ # coffee-shop-rewards2 -# Coreye’s Coffee Cafe (Triple C’s) +Triple C's -### “Coffee. Code. Consistency.” +## Objective -Welcome to Triple C’s. +Build a Java console application that manages a coffee shop’s menu and a customer loyalty program. You will practice **Object-Oriented Programming (OOP)** by creating custom classes, managing data with loops, and using logic to award free drinks. -We serve: +## Core Requirements -* Strong coffee -* Clean code -* Clear logic +### 1. The `CoffeeItem` Class -You’ve been hired to build the rewards system. +This class represents a drink on the menu. -Don’t let the Bronze-tier customers finesse free drinks. - ---- - -## The Mission - -Customers: - -* Order items -* Earn points -* Unlock tiers -* Try to redeem rewards - -You: - -* Build the system -* Keep it organized -* Make sure the math is correct - -No arrays. -No lists. -Just solid fundamentals. - ---- - -## 📁 Required Files - -``` -Customer.java -Purchase.java -Main.java -``` - ---- - -# Level 1 — “Open the Shop” - -Create a `Customer`. - -Fields: - -* name -* phoneNumber -* points - -Include: - -* Default constructor -* Parameterized constructor -* Getters and setters - -Create multiple customers. -Let them earn points. -Print their totals. - -Nobody starts Gold at Triple C’s. - ---- - -# Level 2 — “Run the Register” - -Create a `Purchase` class. - -Each item must know: - -* itemName -* price -* isDrink - -Create at least **6 menu items**. - -No arrays. -Just individual object variables. - ---- - -## ☕ Ordering System +* **Attributes:** Name and price. +* **Encapsulation:** Use `private` fields with **Getters and Setters**. +* **Constructor:** Initialize the name and price when a new drink is created. +### 2. The `Customer` Class -The menu must: +This class tracks individual shoppers and their progress toward a reward. -* Display at least once -* Allow customers to choose items -* Determine how points are chosen +* **Attributes:** Name, email, and `drinksPurchased` (an integer). +* **Methods:** * Create a method to increment the drink count. +* 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). -Update the customer’s points correctly. ---- - -# Level 3 — “Status Matters” - -Customers unlock tiers: - -* Bronze -* Silver -* Gold - -Add redemption: - -Free Drink = 100 points -If they don’t have enough → deny -If they do → subtract points +### 3. The Shop Logic (`Main.java`) -At the end, print: +This is where your program runs. You should: -Name | Tier | Points - -Clean. Clear. Professional. +* **Instantiate Objects:** Create at least three different `CoffeeItem` objects. +* **Control Flow:** Use an `if-else` statement to determine if a customer pays full price or $0 based on their reward status. +* **Loops:** Use a `while` or `for` loop to simulate a "Daily Sales" cycle, allowing multiple customers to buy drinks until the shop closes. --- -# Level 4 — “Make It Feel Like a Real Checkout” - -Triple C’s runs smooth. - -While the customer is ordering: - -* Track their **session total spent** -* Print each item as it’s ordered (like a receipt) - -When they finish ordering, print: +## The Challenge -* Session total -* Points earned during this session -* Updated total customer points +1. **The "Golden Ticket":** Add logic so that if a customer spends over $20 in a single transaction, they get a "bonus" point toward their rewards. +2. **Input Validation:** Use a `Scanner` to take user input. Ensure the program doesn't crash if someone enters a negative number or an invalid menu selection. -Make it feel like a real checkout screen. +## Example Output +```text +Welcome to Triple Cs! +Customer: Alex | Drinks toward reward: 4 +Alex purchased a Latte ($4.50). +CONGRATS! Reward reached. Next drink is on us! From 285c95794929529b848dc829f0d46983115fe758 Mon Sep 17 00:00:00 2001 From: Derwin Bell Date: Tue, 17 Feb 2026 11:24:55 -0500 Subject: [PATCH 3/4] classes done --- .../{Purchase.java => CoffeeItem.java} | 14 +- src/main/java/derwinbell/Customer.java | 38 +++- src/main/java/derwinbell/Main.java | 178 ++++++++---------- 3 files changed, 118 insertions(+), 112 deletions(-) rename src/main/java/derwinbell/{Purchase.java => CoffeeItem.java} (60%) diff --git a/src/main/java/derwinbell/Purchase.java b/src/main/java/derwinbell/CoffeeItem.java similarity index 60% rename from src/main/java/derwinbell/Purchase.java rename to src/main/java/derwinbell/CoffeeItem.java index 06f95ee..c70d605 100644 --- a/src/main/java/derwinbell/Purchase.java +++ b/src/main/java/derwinbell/CoffeeItem.java @@ -1,16 +1,16 @@ package derwinbell; -public class Purchase { +public class CoffeeItem { private String itemName; private double price; - private boolean isDrink; - public Purchase(String itemName, double price, boolean isDrink){ + + public CoffeeItem(String itemName, double price ){ this.itemName = itemName; this.price = price; - this.isDrink = isDrink; + } @@ -30,11 +30,5 @@ public void setPrice(double price) { this.price = price; } - public boolean getDrink() { - return isDrink; - } - public void setDrink(boolean drink) { - isDrink = drink; - } } diff --git a/src/main/java/derwinbell/Customer.java b/src/main/java/derwinbell/Customer.java index eba64f7..05c1a07 100644 --- a/src/main/java/derwinbell/Customer.java +++ b/src/main/java/derwinbell/Customer.java @@ -6,12 +6,20 @@ public class Customer { private String phoneNumber; - private int points; - public Customer(String name, String phoneNumber, int points){ + + private int drinksPurchase; + + public Customer(){ + this("Guest", "000-000-0000", 0); + } + + public Customer(String name, String phoneNumber, int drinksPurchase){ this.name = name; this.phoneNumber = phoneNumber; - this.points = points; + + this.drinksPurchase = drinksPurchase; + } @@ -31,11 +39,27 @@ public void setPhoneNumber(String phoneNumber) { this.phoneNumber = phoneNumber; } - public int getPoints() { - return points; + + + public int getDrinksPurchase() { + return drinksPurchase; } - public void setPoints(int points) { - this.points = points; + public void setDrinksPurchase(int drinksPurchase) { + this.drinksPurchase = drinksPurchase; + } + + public int count(int drinks){ + setDrinksPurchase(drinks); + + return drinks; + } + + public void reward(int drinks){ + if(drinks >= 5){ + System.out.println("CONGRATS! Reward reached. Next drink is on us!"); + + } + } } diff --git a/src/main/java/derwinbell/Main.java b/src/main/java/derwinbell/Main.java index c538c49..1f1b157 100644 --- a/src/main/java/derwinbell/Main.java +++ b/src/main/java/derwinbell/Main.java @@ -7,13 +7,12 @@ public class Main { public static void menuApp(){ - Customer customer = new Customer("Derwin", "302-605-5552", 0); - Purchase purchase = new Purchase("", 0, true); + Customer customer = new Customer(); + CoffeeItem purchase = new CoffeeItem("", 0); Scanner scan = new Scanner(System.in); String playAgain; - int points = 0; - String tier = "Bronze"; + int drinks = 0; @@ -22,112 +21,101 @@ public static void menuApp(){ System.out.println("Whats your phone number?"); customer.setPhoneNumber(scan.nextLine()); - System.out.println("Your name is " + customer.getName() + "\nPhone Number: " + customer.getPhoneNumber() + "\nPoints: " + customer.getPoints()); + System.out.println("Your name is " + customer.getName() + "\nPhone Number: " + customer.getPhoneNumber()); + do { playAgain = "n"; - - if(tier.equals("Bronze") && points >= 200) { - System.out.println("Hey nigga you want to go up a Tier? \nits 200 points to go up to SILVER (y/n)"); - String choice = scan.next(); - if(choice.equals("y")) { - System.out.println("Congrats nigga, you made it"); - tier = "Silver"; - points-=200; - scan.nextLine() ; + System.out.println(customer.getName() + "| Drinks Toward Rewards: " + customer.getDrinksPurchase()); + if(customer.getDrinksPurchase() >= 5){ + customer.reward(drinks); + drinks = 0; + int freeDrink = scan.nextInt(); + switch (freeDrink){ + case 1: + purchase.setItemName("Espresso"); + purchase.setPrice(0); + break; + + case 2: + purchase.setItemName("Latte"); + purchase.setPrice(0); + break; + case 3: + purchase.setItemName("Cappuccino"); + purchase.setPrice(0); + break; + case 4: + purchase.setItemName("Americano"); + purchase.setPrice(0); + break; + case 5: + purchase.setItemName("Mocha"); + purchase.setPrice(0); + break; + case 6: + purchase.setItemName("Cold Brew"); + purchase.setPrice(0); + break; } - else if(choice.equals("n")) { - System.out.println("oh alright, broke ass nigga"); - scan.nextLine() ; - } - } - else if (tier.equals("Silver") && points >= 400){ - System.out.println("Damn Big Back\n you keep coming back! \nits 400 points to go up to GOLD you want in? (y/n)"); - String choice = scan.next(); - if(choice.equals("y")) { - System.out.println("ofc your fat ass would"); - tier = "Gold"; - points-=400; - } - else if(choice.equals("n")) { - System.out.println("oh fasho, maybe you can invest in a gym membership then"); - - } } + else{ + System.out.println("Select item\n1. Espresso 5.00\n2. Latte 2.00\n3. Cappuccino 15.00\n4. Americano 4.00\n5. Mocha 2.50\n6. Cold Brew 1.50"); + int userInput = scan.nextInt(); - System.out.println("its 100 points for a free drink, do you want it? (y/n)"); - String freeDrink = scan.nextLine(); - - if(freeDrink.equals("y")) - { - if(points >= 100){ - System.out.println("Here's your free drink!"); - } - else { - System.out.println("nigga that's not enough"); - points-=100; + if(userInput > 6 || userInput < 1) { + System.out.println("invalid "); + continue; } - } - else if (freeDrink.equals("n")){ - System.out.println("Okay, what would you like today?"); - } - else { - System.out.println("Invalid"); - } - - - System.out.println("Select item\n1. Ramen Noodles 5.00\n2. Sprite 2.00\n3. TV Dinner 15.00\n4. Chips 4.00\n5. Diet Coke 2.50\n6. Fruit 1.50"); - int userInput = scan.nextInt(); - - if(userInput > 8 || userInput < 1) { - System.out.println("invalid "); - continue; + switch (userInput){ + case 1: + purchase.setItemName("Espresso"); + purchase.setPrice(5.94); + + customer.count(drinks++); + break; + + case 2: + purchase.setItemName("Latte"); + purchase.setPrice(2.88); + + customer.count(drinks++); + break; + case 3: + purchase.setItemName("Cappuccino"); + purchase.setPrice(15.99); + + customer.count(drinks++); + break; + case 4: + purchase.setItemName("Americano"); + purchase.setPrice(4.23); + + customer.count(drinks++); + break; + case 5: + purchase.setItemName("Mocha"); + purchase.setPrice(2.59); + + customer.count(drinks++); + break; + case 6: + purchase.setItemName("Cold Brew"); + purchase.setPrice(1.52); + + customer.count(drinks++); + break; + } } + customer.setDrinksPurchase(customer.count(drinks)); + System.out.println("You want " + purchase.getItemName() + " " + "it is $" + purchase.getPrice()); - switch (userInput){ - case 1: - purchase.setItemName("Ramen Noodles"); - purchase.setPrice(5.94); - points += 90; - break; - - case 2: - purchase.setItemName("Sprite"); - purchase.setPrice(2.88); - points += 50; - break; - case 3: - purchase.setItemName("TV Dinner"); - purchase.setPrice(15.99); - points += 100; - break; - case 4: - purchase.setItemName("Chips"); - purchase.setPrice(4.23); - points += 60; - break; - case 5: - purchase.setItemName("Diet Coke"); - purchase.setPrice(2.59); - points += 50; - break; - case 6: - purchase.setItemName("Fruit"); - purchase.setPrice(1.52); - points += 20; - break; - } - customer.setPoints(points); - - System.out.println("You want " + purchase.getItemName() + " " + "it is $" + purchase.getPrice()); - System.out.println("You get " + customer.getPoints() + " points" ); - System.out.println(customer.getName() + "|" + tier + "|" + customer.getPoints()); while (true) { System.out.print("is That all?? (y/n): "); From e83042a4b97ab64c5080d02c6bc1a63ee310930e Mon Sep 17 00:00:00 2001 From: Derwin Bell Date: Thu, 19 Feb 2026 10:58:39 -0500 Subject: [PATCH 4/4] Done CCC --- src/main/java/derwinbell/Customer.java | 8 ++------ src/main/java/derwinbell/Main.java | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/main/java/derwinbell/Customer.java b/src/main/java/derwinbell/Customer.java index 05c1a07..c15271a 100644 --- a/src/main/java/derwinbell/Customer.java +++ b/src/main/java/derwinbell/Customer.java @@ -55,11 +55,7 @@ public int count(int drinks){ return drinks; } - public void reward(int drinks){ - if(drinks >= 5){ - System.out.println("CONGRATS! Reward reached. Next drink is on us!"); - - } - + public boolean hasReward() { + return this.drinksPurchase >= 5; } } diff --git a/src/main/java/derwinbell/Main.java b/src/main/java/derwinbell/Main.java index 1f1b157..33ac3c6 100644 --- a/src/main/java/derwinbell/Main.java +++ b/src/main/java/derwinbell/Main.java @@ -28,8 +28,10 @@ public static void menuApp(){ do { playAgain = "n"; System.out.println(customer.getName() + "| Drinks Toward Rewards: " + customer.getDrinksPurchase()); - if(customer.getDrinksPurchase() >= 5){ - customer.reward(drinks); + if(customer.hasReward()){ + + System.out.println("CONGRATS! Reward reached. Next drink is FREE!"); + drinks = 0; int freeDrink = scan.nextInt(); switch (freeDrink){ @@ -58,12 +60,15 @@ public static void menuApp(){ purchase.setItemName("Cold Brew"); purchase.setPrice(0); break; + default: + System.out.println("Invalid"); + break; } } else{ - System.out.println("Select item\n1. Espresso 5.00\n2. Latte 2.00\n3. Cappuccino 15.00\n4. Americano 4.00\n5. Mocha 2.50\n6. Cold Brew 1.50"); + System.out.println("Select item #\n1. Espresso 5.00\n2. Latte 2.00\n3. Cappuccino 15.00\n4. Americano 4.00\n5. Mocha 2.50\n6. Cold Brew 1.50"); int userInput = scan.nextInt(); if(userInput > 6 || userInput < 1) { @@ -109,6 +114,10 @@ public static void menuApp(){ customer.count(drinks++); break; + + default: + System.out.println("Invalid"); + break; } } customer.setDrinksPurchase(customer.count(drinks));