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..a9aa18f 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/BuyAgain.java b/src/main/java/org/codedifferently/BuyAgain.java
new file mode 100644
index 0000000..9530193
--- /dev/null
+++ b/src/main/java/org/codedifferently/BuyAgain.java
@@ -0,0 +1,50 @@
+package org.codedifferently;
+
+import java.util.Scanner;
+
+public class BuyAgain {
+//if I want this loop to run, I have to figure out why points aren't getting update properly
+ public static boolean buyagain(Customer cust1, Scanner scan, CoffeeItem item1, CoffeeItem item2, CoffeeItem item3, CoffeeItem item4, CoffeeItem item5, CoffeeItem item6) {
+ boolean isInvalid = true;
+ String check2 = "";
+ while (isInvalid) {
+ System.out.print("\nπ Would you like to order anything else? (y/n): ");
+ check2 = scan.next();
+
+ if (check2.equalsIgnoreCase("y")){
+ isInvalid = false;
+ }else if (check2.equalsIgnoreCase("n")){
+ isInvalid = false;
+ }else{
+ System.out.println("Please enter a valid input! (y/n)");
+ }
+ }
+
+ if (check2.equals("y")) {
+ System.out.println("\n========================================");
+ System.out.println(" β TRIPLE C'S MENU β");
+ System.out.println("========================================");
+
+ System.out.printf(" 1) %-22s $%6.2f%n", item1.getItemName(), item1.getPrice());
+ System.out.printf(" 2) %-22s $%6.2f%n", item2.getItemName(), item2.getPrice());
+ System.out.printf(" 3) %-22s $%6.2f%n", item3.getItemName(), item3.getPrice());
+ System.out.printf(" 4) %-22s $%6.2f%n", item4.getItemName(), item4.getPrice());
+ System.out.printf(" 5) %-22s $%6.2f%n", item5.getItemName(), item5.getPrice());
+ System.out.printf(" 6) %-22s $%6.2f%n", item6.getItemName(), item6.getPrice());
+
+ System.out.println("----------------------------------------");
+ System.out.println(" 7) Proceed to Checkout π");
+ System.out.println("========================================");
+
+ System.out.print("π Please select an option: ");
+ return true;
+ } else {
+ System.out.println("\n========================================");
+ System.out.println(" β Thank you for visiting Triple C's!");
+ System.out.println(" We hope to see you again soon.");
+ System.out.println(" Have a wonderful day! π");
+ System.out.println("========================================\n");
+ return false;
+ }
+ }
+}
diff --git a/src/main/java/org/codedifferently/Checkout.java b/src/main/java/org/codedifferently/Checkout.java
new file mode 100644
index 0000000..e5b089e
--- /dev/null
+++ b/src/main/java/org/codedifferently/Checkout.java
@@ -0,0 +1,180 @@
+package org.codedifferently;
+
+import java.util.Scanner;
+
+public class Checkout {
+
+ public static void checkout(Customer cust1, Scanner scan, CoffeeItem item1, CoffeeItem item2, CoffeeItem item3, CoffeeItem item4, CoffeeItem item5, CoffeeItem item6){
+ //customer is alex checkout
+ //for each item in the cart, add points based on total price over 10
+
+ //this should give total number of points within our cart
+
+ //would you like to redeem?
+
+ //if yes, check if enough points,
+
+ //
+
+
+ if (cust1.getCost(cust1.getMyCart()) >= 20){
+ System.out.println("Congratulations! You earned 1 bonus point for spending over $20");
+ cust1.setMyPoints(cust1.getMyCart());
+ cust1.incrementPoints();
+ }else{
+ cust1.setMyPoints(cust1.getMyCart());
+ }
+ System.out.println("\n========================================");
+ System.out.printf(" β Loyalty Points Balance: %d β%n", cust1.getPoints());
+ System.out.println("========================================");
+
+ boolean isInvalid = true;
+ String check = "";
+ while (isInvalid) {
+ System.out.print("Redeem points for rewards? (y/n): ");
+ check = scan.next();
+
+ if (check.equalsIgnoreCase("y")){
+ isInvalid = false;
+ }else if (check.equalsIgnoreCase("n")){
+ isInvalid = false;
+ }else{
+ System.out.println("Please enter a valid input! (y/n)");
+ }
+ }
+
+ if (check.equals("y")){
+ boolean isPointShopping = true;
+ do{
+ System.out.println("\n========================================");
+ System.out.println(" β TRIPLE C'S REWARDS β");
+ System.out.println("========================================");
+
+ System.out.printf(" π― Current Points Balance: %d%n%n", cust1.getPoints());
+
+ System.out.printf(" 1) %-22s %6d pts%n", item1.getItemName(), item1.getPointCost());
+ System.out.printf(" 2) %-22s %6d pts%n", item2.getItemName(), item2.getPointCost());
+ System.out.printf(" 3) %-22s %6d pts%n", item3.getItemName(), item3.getPointCost());
+ System.out.printf(" 4) %-22s %6d pts%n", item4.getItemName(), item4.getPointCost());
+ System.out.printf(" 5) %-22s %6d pts%n", item5.getItemName(), item5.getPointCost());
+ System.out.printf(" 6) %-22s %6d pts%n", item6.getItemName(), item6.getPointCost());
+
+ System.out.println("----------------------------------------");
+ System.out.println(" 7) Finish Redeeming");
+ System.out.println("========================================");
+
+ System.out.print("π Select a reward: ");
+ String selection = scan.next();
+
+
+ switch(selection){
+ case "1":
+ //if user has enough points
+ //spend points on the item and subtract points spent
+ //else say they don't have enough for this item
+ if(cust1.getPoints() > item1.getPointCost()){
+ //spend points on item and subtract points spent
+ System.out.printf("\nπ Congratulations! You redeemed %s for %d points.%n",
+ item1.getItemName(),
+ item1.getPointCost()); //subtract points
+ cust1.reducePoints(cust1.getPoints(), item1.getPointCost());
+ }else{
+ System.out.println("\nβ We're sorry, you don't have enough points for that reward.");
+ System.out.print("Earn more points or choose another option: "); }
+ break;
+ case "2":
+ if(cust1.getPoints() > item2.getPointCost()){
+ //spend points on item and subtract points spent
+ System.out.printf("\nπ Congratulations! You redeemed %s for %d points.%n",
+ item2.getItemName(),
+ item2.getPointCost()); //subtract points
+ cust1.reducePoints(cust1.getPoints(), item2.getPointCost());
+ }else{
+ System.out.println("\nβ We're sorry, you don't have enough points for that reward.");
+ System.out.print("Earn more points or choose another option: ");
+ }
+ break;
+ case "3":
+ if(cust1.getPoints() > item3.getPointCost()){
+ //spend points on item and subtract points spent
+ System.out.printf("\nπ Congratulations! You redeemed %s for %d points.%n",
+ item3.getItemName(),
+ item3.getPointCost()); //subtract points
+ cust1.reducePoints(cust1.getPoints(), item3.getPointCost());
+ }else{
+ System.out.println("\nβ We're sorry, you don't have enough points for that reward.");
+ System.out.print("Earn more points or choose another option: ");
+ }
+ break;
+ case "4":
+ if(cust1.getPoints() > item4.getPointCost()){
+ //spend points on item and subtract points spent
+ System.out.printf("\nπ Congratulations! You redeemed %s for %d points.%n",
+ item4.getItemName(),
+ item4.getPointCost()); //subtract points
+ cust1.reducePoints(cust1.getPoints(), item4.getPointCost());
+ }else{
+ System.out.println("\nβ We're sorry, you don't have enough points for that reward.");
+ System.out.print("Earn more points or choose another option: ");
+ }
+ break;
+ case "5":
+ if(cust1.getPoints() > item5.getPointCost()){
+ //spend points on item and subtract points spent
+ System.out.printf("\nπ Congratulations! You redeemed %s for %d points.%n",
+ item5.getItemName(),
+ item5.getPointCost()); //subtract points
+ cust1.reducePoints(cust1.getPoints(), item5.getPointCost());
+ }else{
+ System.out.println("\nβ We're sorry, you don't have enough points for that reward.");
+ System.out.print("Earn more points or choose another option: ");
+ }
+ break;
+ case "6":
+ if(cust1.getPoints() > item6.getPointCost()){
+ //spend points on item and subtract points spent
+ System.out.printf("\nπ Congratulations! You redeemed %s for %d points.%n",
+ item6.getItemName(),
+ item6.getPointCost()); //subtract points
+ cust1.reducePoints(cust1.getPoints(), item6.getPointCost());
+ }else{
+ System.out.println("\nβ We're sorry, you don't have enough points for that reward.");
+ System.out.print("Earn more points or choose another option: ");
+ }
+ break;
+ case "7":
+ //done point shopping
+ isPointShopping = false;
+ break;
+ default:
+ System.out.println("\nβ That option isnβt on the menu.");
+ System.out.print("Try selecting one of the listed numbers (1-7): ");
+ break;
+ }
+ //menu items and point prices
+ }while(isPointShopping);
+
+ //use points
+ //ask what they want to redeem for
+ //if they have enough, subtract
+ //if not, tell them they don't have enough
+
+ cust1.setTier(cust1.getPoints());
+
+ System.out.printf("\nπ€ Customer: %s | π
Tier: %s | π― Points: %d%n%n",
+ cust1.getName(),
+ cust1.getTier(),
+ cust1.getPoints());
+
+ }else{
+ //print final output
+ cust1.setTier(cust1.getPoints());
+
+ System.out.printf("\nπ€ Customer: %s | π
Tier: %s | π― Points: %d%n%n",
+ cust1.getName(),
+ cust1.getTier(),
+ cust1.getPoints());
+ }
+
+ }
+}
diff --git a/src/main/java/org/codedifferently/CoffeeItem.java b/src/main/java/org/codedifferently/CoffeeItem.java
new file mode 100644
index 0000000..2ab1022
--- /dev/null
+++ b/src/main/java/org/codedifferently/CoffeeItem.java
@@ -0,0 +1,47 @@
+package org.codedifferently;
+
+public class CoffeeItem {
+ private String itemName;
+ private double price;
+ private boolean isDrink;
+ private int pointCost;
+
+ public CoffeeItem(String itemName, double price, boolean isDrink){
+ this.itemName = itemName;
+ this.price = price;
+ this.isDrink = isDrink;
+ this.pointCost = (int) (price/10 * 3.2);
+ }
+
+ public boolean isDrink() {
+ return isDrink;
+ }
+
+ public double getPrice() {
+ return price;
+ }
+
+ public String getItemName() {
+ return itemName;
+ }
+
+ public void setDrink(boolean drink) {
+ isDrink = drink;
+ }
+
+ public void setItemName(String itemName) {
+ this.itemName = itemName;
+ }
+
+ public void setPrice(double price) {
+ this.price = price;
+ }
+
+ public int getPointCost() {
+ return pointCost;
+ }
+
+ public void setPointCost(int cost){
+ this.pointCost = cost;
+ }
+}
diff --git a/src/main/java/org/codedifferently/Customer.java b/src/main/java/org/codedifferently/Customer.java
new file mode 100644
index 0000000..7e3aeeb
--- /dev/null
+++ b/src/main/java/org/codedifferently/Customer.java
@@ -0,0 +1,99 @@
+package org.codedifferently;
+import java.util.ArrayList;
+import java.util.List;
+
+
+public class Customer {
+
+
+ private String name;
+ private String phoneNumber;
+ private int points;
+ private List myCart = new ArrayList<>();
+ private String tier = "No Tier";
+
+ public Customer (){
+ this.name = "Bob";
+ this.phoneNumber = "302-302-3023";
+ this.points = 0;
+
+ }
+ public Customer (String name, String phoneNumber, int points){
+ this.name = name;
+ this.phoneNumber = phoneNumber;
+ this.points = points;
+ }
+
+ public int getPoints() {
+ return points;
+ }
+
+ public void incrementPoints() { this.points += 1;}
+
+ public String getName() {
+ return name;
+ }
+
+ public String getPhoneNumber() {
+ return phoneNumber;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setPhoneNumber(String phoneNumber) {
+ this.phoneNumber = phoneNumber;
+ }
+
+ public void setPoints(int points) {
+ this.points = points;
+ }
+
+ public void addToCart(CoffeeItem item){
+ this.myCart.add(item);
+ }
+
+ public void clearCart(){this.myCart.clear();}
+
+ public List getMyCart() {
+ return myCart;
+ }
+
+ public double getCost(List carts){
+ double total = 0;
+ for (CoffeeItem cart : carts) {
+
+ total = total + cart.getPrice();
+
+ }
+ return total;
+ }
+
+
+ public void setMyPoints(List cart){
+ double totalCost = getCost(cart);
+ double myPoints = totalCost/10;
+ this.points = this.points + (int) myPoints;
+ this.myCart.clear();
+ }
+
+ public void reducePoints(int startPoints, int spentPoints){
+ this.points = (startPoints - spentPoints);
+ }
+
+ public void setTier(int points){
+ if(points >= 10){
+ this.tier = "Gold";
+ }else if (points >= 5){
+ this.tier = "Silver";
+ }else if (points >= 1){
+ this.tier = "Bronze";
+
+ }
+ }
+
+ public String getTier(){
+ return tier;
+ }
+}
diff --git a/src/main/java/org/codedifferently/InputLoop.java b/src/main/java/org/codedifferently/InputLoop.java
new file mode 100644
index 0000000..0edcc69
--- /dev/null
+++ b/src/main/java/org/codedifferently/InputLoop.java
@@ -0,0 +1,154 @@
+package org.codedifferently;
+
+import java.util.ArrayList;
+import java.util.Scanner;
+
+public class InputLoop {
+
+ public static void inputloop(boolean isRunning, boolean isRunning2, Scanner scan, ArrayList myCustomers, Customer cust1, CoffeeItem item1, CoffeeItem item2, CoffeeItem item3, CoffeeItem item4, CoffeeItem item5, CoffeeItem item6) {
+ while (isRunning) {
+ System.out.println("==================================");
+ System.out.println(" β Welcome to Triple C's β");
+ System.out.println("==================================");
+ System.out.println("Brewing addictions, one cup at a time.");
+ System.out.println("--------------------------------------");
+ System.out.println("What is your name?\n");
+ String custName = scan.next();
+
+
+ //if custName exists in the array, we'll find and use first occurrence
+ boolean exists = false;
+ for (Customer cust : myCustomers) {
+ if (cust.getName().equals(custName)) {
+ cust1 = cust;
+ exists = true;
+ break;
+ }
+ }
+ if (exists) {
+ //customer exists, we already set it, do nothing
+ } //otherwise new customer
+ else {
+ //create new customer
+ System.out.println("\nβ First time at Triple C's? We love new faces!");
+ System.out.println("Letβs get you in the system.");
+ System.out.print("π± Enter your phone number: ");
+
+ String phoneNumber;
+
+ while (true) {
+ System.out.print("Enter phone number (xxx-xxx-xxxx): ");
+ phoneNumber = scan.next();
+
+ if (phoneNumber.matches("\\d{3}-\\d{3}-\\d{4}")) {
+ break; // valid format, exit loop
+ } else {
+ System.out.println("Invalid format. Please use xxx-xxx-xxxx.");
+ }
+ }
+
+ cust1 = new Customer(custName, phoneNumber, 0);
+ //add customer to our array list
+ myCustomers.add(cust1);
+
+ }
+
+ //menu
+ System.out.println("\n======================================");
+ System.out.println(" β TRIPLE C'S MENU β");
+ System.out.println("======================================");
+
+ System.out.printf(" 1) %-20s $%5.2f%n", item1.getItemName(), item1.getPrice());
+ System.out.printf(" 2) %-20s $%5.2f%n", item2.getItemName(), item2.getPrice());
+ System.out.printf(" 3) %-20s $%5.2f%n", item3.getItemName(), item3.getPrice());
+ System.out.printf(" 4) %-20s $%5.2f%n", item4.getItemName(), item4.getPrice());
+ System.out.printf(" 5) %-20s $%5.2f%n", item5.getItemName(), item5.getPrice());
+ System.out.printf(" 6) %-20s $%5.2f%n", item6.getItemName(), item6.getPrice());
+
+ System.out.println("--------------------------------------");
+ System.out.println(" 7) Proceed to Checkout and Redeem Points π");
+ System.out.println("======================================");
+
+ System.out.print("π What would you like to order? ");
+
+ do {
+ String userInput = scan.next();
+ switch (userInput) {
+ case "1":
+ //CoffeeItem Latte
+ cust1.addToCart(item1);
+ System.out.println("\nβ
Latte added to your cart!");
+ System.out.println("--------------------------------------");
+ System.out.print("β Add another item or press 7 to checkout: ");
+
+ break;
+ case "2":
+ //CoffeeItem Cold Brew
+ cust1.addToCart(item2);
+ System.out.println("\nβ
Cold Brew added to your cart!");
+ System.out.println("--------------------------------------");
+ System.out.print("β Add another item or press 7 to checkout: ");
+ break;
+ case "3":
+
+ cust1.addToCart(item3);
+ System.out.println("\nβ
Hot Chocolate added to your cart!");
+ System.out.println("--------------------------------------");
+ System.out.print("β Add another item or press 7 to checkout: ");
+ break;
+ case "4":
+ //CoffeeItem Cappucino
+ cust1.addToCart(item4);
+ System.out.println("\nβ
Cappucino added to your cart!");
+ System.out.println("--------------------------------------");
+ System.out.print("β Add another item or press 7 to checkout: ");
+ break;
+ case "5":
+ //CoffeeItem Mocha
+
+ cust1.addToCart(item5);
+ System.out.println("\nβ
Mocha added to your cart!");
+ System.out.println("--------------------------------------");
+ System.out.print("β Add another item or press 7 to checkout: ");
+ break;
+ case "6":
+ //CoffeeItem Egg Roll
+ cust1.addToCart(item6);
+ System.out.println("\nβ
Egg Roll added to your cart!");
+ System.out.println("--------------------------------------");
+ System.out.print("β Add another item or press 7 to checkout: ");
+ break;
+
+ case "7":
+ //checkout
+
+ Checkout.checkout(cust1, scan, item1, item2, item3, item4, item5, item6);
+ isRunning2 = BuyAgain.buyagain(cust1, scan, item1, item2, item3, item4, item5, item6);
+ break;
+
+ default:
+ System.out.println("\nβ Oops! Thatβs not on the menu.");
+ System.out.print("Please select a valid option: ");
+ break;
+ }
+ } while (isRunning2);
+
+ boolean isInvalidInput = true;
+ while (isInvalidInput) {
+ System.out.print("\nπ Is the store closing for the day? (y/n): ");
+ String userInput = scan.next();
+ if (userInput.equalsIgnoreCase("y")) {
+ isRunning = false;
+ isInvalidInput = false;
+ } else if (userInput.equalsIgnoreCase("n")) {
+ //keep running so we reset our other loop condition
+ isRunning2 = true;
+ isInvalidInput = false;
+ } else {
+ System.out.println("Please enter y or n");
+ }
+ }
+
+ }
+ }
+}
diff --git a/src/main/java/org/codedifferently/Main.java b/src/main/java/org/codedifferently/Main.java
index 435139b..84e7c04 100644
--- a/src/main/java/org/codedifferently/Main.java
+++ b/src/main/java/org/codedifferently/Main.java
@@ -1,17 +1,45 @@
package org.codedifferently;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Scanner;
+
+
//TIP To Run code, press or
// click the icon in the gutter.
+//when i check the cart size, if total cost is over 20 give a bonus point
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);
+
+ //create some customers
+ Customer cust1 = new Customer("Alex", "302-314-5204", 0);
+ Customer cust2 = new Customer("Bobby", "302-111-1111", 0);
+ Customer cust3 = new Customer("Manny", "911-911-9111", 0);
+ ArrayList myCustomers = new ArrayList<>();
+
+ myCustomers.add(cust1);
+ myCustomers.add(cust2);
+ myCustomers.add(cust3);
+
+
+ //create some menu items
+ CoffeeItem item1 = new CoffeeItem("Latte", 10, true);
+ CoffeeItem item2 = new CoffeeItem("Cold Brew", 10, true);
+ CoffeeItem item3 = new CoffeeItem("Hot Chocolate", 10, true);
+ CoffeeItem item4 = new CoffeeItem("Cappucino", 10, true);
+ CoffeeItem item5 = new CoffeeItem("Mocha", 10, true);
+ CoffeeItem item6 = new CoffeeItem("Egg Roll", 10, false);
+
+
+ //create scanner
+
+ Scanner scan = new Scanner(System.in);
+
+ boolean isRunning = true;
+ boolean isRunning2 = true;
+ //
+
+ InputLoop.inputloop(isRunning, isRunning2, scan, myCustomers, cust1, item1, item2, item3, item4, item5, item6);
+
}
}
-}
\ No newline at end of file