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.

151 changes: 28 additions & 123 deletions README.md
Original file line number Diff line number Diff line change
@@ -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!


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

public class CoffeeItem {
// Represents the name of the item.
private String name;
// Represents the price of the item
private final double price;

// Constructor
public CoffeeItem(String name, double price) {
this.name = name;
this.price = price;
}

// Returns the name of the item.
public String getName() {
return name;
}

// Returns the price of the item.
public double getPrice() {
return price;
}
}
87 changes: 87 additions & 0 deletions src/main/java/org/codedifferently/Customer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package org.codedifferently;

public class Customer {
// Represents the customer's name.
private String name;
// Represents the customer's email address.
private String email;
// Represents the total number of drinks that the customer has purchased.
private int drinksPurchased;
// Represents whether the customer has a reward active
private boolean rewardActive;
// Represents the customer's tab.
private double tab;

// Constructor
public Customer(String name, String email) {
this.name = name;
this.email = email;
this.drinksPurchased = 0;
this.rewardActive = false;
}

// Returns the current customer's name.
public String getName() {
return name;
}

// Returns the current customer's email.
public String getEmail() {
return email;
}

// Sets the current customer's name.
public void setName(String name) {
this.name = name;
}

// Sets the current customer's email.
public void setEmail(String email) {
this.email = email;
}

// Increments drinksPurchased by 1.
public void setDrinksPurchased() {
this.drinksPurchased++;
}

// Sets the amount of drinks that the customer's bought to 0.
public void setDrinksPurchased(int num) {
this.drinksPurchased = 0;
}

// Returns a boolean representing whether the current customer has a reward active.
public boolean getRewardActive() {
return this.rewardActive;
}

// Returns the total number of drinks that the current customer has purchased.
public int getDrinksPurchased() {
return this.drinksPurchased;
}

// Sets whether the current customer has a reward active.
public void setRewardActive(boolean status) {
this.rewardActive = status;
}

// A method that returns a boolean representing whether the current customer is eligible for a reward.
public boolean isEligible() {
if (this.drinksPurchased == 4) {
setRewardActive(true);
return true;
} else {
return false;
}
}

// Gets the current customer's tab.
public double getTab() {
return tab;
}

// Sets the current customer's tab.
public void setTab(double tab) {
this.tab += tab;
}
}
20 changes: 12 additions & 8 deletions src/main/java/org/codedifferently/Main.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
package org.codedifferently;

import java.util.Scanner;

//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!");
Scanner sc = new Scanner(System.in);
// Creates a customer object for the menu
Customer patron = Welcome.greet(sc);

// Instantiates 3 new items to be sold on the menu
CoffeeItem cappuccino = new CoffeeItem("Cappuccino", 4.75);
CoffeeItem ICL = new CoffeeItem("Iced Caramel Latte", 5.95);
CoffeeItem coldBrew = new CoffeeItem("Cold Brew Latte", 4.25);

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);
}
// Displays the menu.
Purchase.displayMenu(patron, cappuccino, ICL, coldBrew, sc);
}
}
Loading