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/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! diff --git a/src/main/java/derwinbell/CoffeeItem.java b/src/main/java/derwinbell/CoffeeItem.java new file mode 100644 index 0000000..c70d605 --- /dev/null +++ b/src/main/java/derwinbell/CoffeeItem.java @@ -0,0 +1,34 @@ +package derwinbell; + +public class CoffeeItem { + private String itemName; + + private double price; + + + + public CoffeeItem(String itemName, double price ){ + this.itemName = itemName; + this.price = price; + + + } + + 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; + } + + +} diff --git a/src/main/java/derwinbell/Customer.java b/src/main/java/derwinbell/Customer.java new file mode 100644 index 0000000..c15271a --- /dev/null +++ b/src/main/java/derwinbell/Customer.java @@ -0,0 +1,61 @@ +package derwinbell; + +public class Customer { + + private String name; + + private String phoneNumber; + + + + 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.drinksPurchase = drinksPurchase; + + + } + + 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 getDrinksPurchase() { + return drinksPurchase; + } + + public void setDrinksPurchase(int drinksPurchase) { + this.drinksPurchase = drinksPurchase; + } + + public int count(int drinks){ + setDrinksPurchase(drinks); + + return drinks; + } + + public boolean hasReward() { + return this.drinksPurchase >= 5; + } +} diff --git a/src/main/java/derwinbell/Main.java b/src/main/java/derwinbell/Main.java new file mode 100644 index 0000000..33ac3c6 --- /dev/null +++ b/src/main/java/derwinbell/Main.java @@ -0,0 +1,155 @@ +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(); + CoffeeItem purchase = new CoffeeItem("", 0); + Scanner scan = new Scanner(System.in); + + String playAgain; + int drinks = 0; + + + + 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()); + + + + do { + playAgain = "n"; + System.out.println(customer.getName() + "| Drinks Toward Rewards: " + customer.getDrinksPurchase()); + if(customer.hasReward()){ + + System.out.println("CONGRATS! Reward reached. Next drink is FREE!"); + + 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; + 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"); + int userInput = scan.nextInt(); + + if(userInput > 6 || 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; + + default: + System.out.println("Invalid"); + break; + } + } + customer.setDrinksPurchase(customer.count(drinks)); + + System.out.println("You want " + purchase.getItemName() + " " + "it is $" + purchase.getPrice()); + + + + 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/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