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
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/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;
+ }
+}
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
+}