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/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 diff --git a/src/main/java/org/codedifferently/masonbrown/Main.java b/src/main/java/org/codedifferently/masonbrown/Main.java new file mode 100644 index 0000000..f5e91ac --- /dev/null +++ b/src/main/java/org/codedifferently/masonbrown/Main.java @@ -0,0 +1,136 @@ +package org.codedifferently.masonbrown; + +import java.util.Scanner; + +public class Main { + + public static void main(String[] args) { + + customer customer = new customer( + "Mason", + 27.99, + "bagel", + 5000, + true, + "Gold", + "3024551922", true); + + Scanner scanner = new Scanner(System.in); + boolean mainmenurunning = true; + + purchase BaconEggandCheese = new purchase(5.95, "Bacon egg and cheese", false, 60, 600); + purchase Bagelwithcreamcheese = new purchase(3.99, "Bagel with cream cheese", false, 40, 400); + purchase chickenandwaffles = new purchase(11.95, "Homestyle chicken and waffles", false, 120, 1200); + purchase steakandeggs = new purchase(18.95, "Steak and eggs", false, 190, 1900); + purchase honeywatertea = new purchase(2.99, "Honey water tea", true, 30, 300); + purchase coffee = new purchase(2.09, "Coffee", true, 20, 200); + + while (mainmenurunning) { + double totaltracker=0.0; + + System.out.println("\nWelcome to Triple C's!"); + System.out.println("Are you a rewards member?"); + System.out.println("1. Yes"); + System.out.println("2. No"); + System.out.println("0. Exit"); + + String stringuserinputmenu = scanner.nextLine(); + + switch (stringuserinputmenu) { + + case "1": + + System.out.println("Enter your phone number:"); + String stringuserinputpn = scanner.nextLine(); + + if (stringuserinputpn.equals(customer.getPhonenumber())) { + + boolean secondmenurunning = true; + + while (secondmenurunning) { + + System.out.println("\nWelcome " + customer.getName()); + System.out.println("You have " + customer.getPointsearned() + " redeemable points."); + System.out.println("Current Tier: " + customer.getCurrenttier()); + System.out.println("What would you like to order?"); + System.out.println("1. Bacon egg and cheese"); + System.out.println("2. Bagel with cream cheese"); + System.out.println("3. Homemade Chicken and Waffles"); + System.out.println("4. Steak and Eggs"); + System.out.println("5. Honey water tea"); + System.out.println("6. Coffee"); + System.out.println("7. Quit this order"); + + String orderinput = scanner.nextLine(); + + switch (orderinput) { + case "1": + BaconEggandCheese.processPurchase(customer, scanner); + customer.updatetier(); + totaltracker+=5.95; + System.out.println("You spent a total of " + totaltracker); + break; + case "2": + Bagelwithcreamcheese.processPurchase(customer, scanner); + customer.updatetier(); + totaltracker+=3.99; + System.out.println("You spent a total of " + totaltracker); + break; + case "3": + chickenandwaffles.processPurchase(customer, scanner); + customer.updatetier(); + totaltracker+=11.95; + System.out.println("You spent a total of " + totaltracker); + break; + case "4": + steakandeggs.processPurchase(customer, scanner); + customer.updatetier(); + totaltracker+=18.95; + System.out.println("You spent a total of " + totaltracker); + break; + case "5": + honeywatertea.processPurchase(customer, scanner); + customer.updatetier(); + totaltracker+=2.99; + System.out.println("You spent a total of " + totaltracker); + break; + + case "6": + coffee.processPurchase(customer, scanner); + customer.updatetier(); + totaltracker+=2.99; + System.out.println("You spent a total of " + totaltracker); + break; + case "7": + secondmenurunning = false; + break; + default: + System.out.println("Invalid selection."); + } + } + + } else { + System.out.println("Invalid member phone number."); + } + + break; + + case "2": + mainmenurunning=false; + customer = customer.signupmenu(); + mainmenurunning = true; + break; + + case "0": + mainmenurunning = false; + break; + + default: + System.out.println("Invalid selection."); + } + } + + scanner.close(); + + } +} diff --git a/src/main/java/org/codedifferently/masonbrown/customer.java b/src/main/java/org/codedifferently/masonbrown/customer.java new file mode 100644 index 0000000..f07b3bc --- /dev/null +++ b/src/main/java/org/codedifferently/masonbrown/customer.java @@ -0,0 +1,124 @@ +package org.codedifferently.masonbrown; +import java.util.Scanner; +public class customer { + private String name; + private double wallet; + private String order; + private int pointsearned; + private boolean canredeem; + private String currenttier; + private String phonenumber; + private boolean cangetfreedrink; + + + //constructor + public customer(String name, double wallet, String order, int pointsearned, boolean canredeem, + String currenttier, String phonenumber, boolean cangetfreedrink){ + this.name= name; + this.wallet=wallet; + this.order=order; + this.pointsearned=pointsearned; + this.canredeem=canredeem; + this.currenttier = currenttier; + this.phonenumber = phonenumber; + this.cangetfreedrink= cangetfreedrink; + //setters + + + }public customer signupmenu() { + Scanner scanner = new Scanner(System.in); + String stringuserinputmenu1; + System.out.println("Would you like to sign up and receive 10% off your purchase?"); + System.out.println("1. Yes" + "\n" + "2. No"); + stringuserinputmenu1 = scanner.nextLine(); + customer newsignup = new customer(" ", 0.0, " ", 0, false, "Bronze", " ", false); + System.out.println("Enter your full name."); + String newusername = newsignup.getName(); + newusername = scanner.nextLine(); + newsignup.setName(newusername); + System.out.println("Enter your phone number"); + stringuserinputmenu1 = scanner.nextLine(); + newsignup.setPhonenumber(stringuserinputmenu1); + System.out.println("Enter your phone number again for verification."); + String phoneverification = scanner.nextLine(); + if (phoneverification.equals(stringuserinputmenu1)) { + System.out.println("Signup was Successful! "); + newsignup = new customer(newusername, 0.0, " ", 0, false, "Bronze", stringuserinputmenu1, false); + newsignup.setPointsearned(0); + newsignup.setCurrenttier("Bronze"); + + + + + } + return newsignup; + } + public void updatetier(){ + if (pointsearned >= 5000) { + currenttier= "Gold"; + } else if (pointsearned >=3000) { + currenttier= "Silver"; + + }else currenttier= "Bronze"; + } + + public void setAmountspent(double amountspent) { + this.wallet = wallet; + } + + public void setCanredeem(boolean canredeem) { + this.canredeem = canredeem; + } + + public void setCurrenttier(String currenttier) { + this.currenttier = currenttier; + updatetier(); + } + + public void setName(String name) { + this.name = name; + } + + public void setOrder(String order) { + this.order = order; + } + + public void setPointsearned(int pointsearned) { + this.pointsearned = pointsearned; + } + + public void setPhonenumber(String phonenumber) { + this.phonenumber = phonenumber; + } + + + //getters + + public double getAmountspent() { + return wallet; + } + + public String getCurrenttier() { + return currenttier; + } + + public String getPhonenumber() { + return phonenumber; + } + + public boolean isCanredeem() { + return canredeem; + } + + public String getName() { + return name; + } + + public String getOrder() { + return order; + } + + public int getPointsearned() { + return pointsearned; + } +} diff --git a/src/main/java/org/codedifferently/masonbrown/purchase.java b/src/main/java/org/codedifferently/masonbrown/purchase.java new file mode 100644 index 0000000..9559281 --- /dev/null +++ b/src/main/java/org/codedifferently/masonbrown/purchase.java @@ -0,0 +1,72 @@ +package org.codedifferently.masonbrown; + +import java.util.Scanner; + +public class purchase { + + private double price; + private String itemname; + private boolean isdrink; + private int itempoints; + private int itempointstobuy; + + + public purchase(double price, String itemname, boolean isdrink, int itempoints, int itempointstobuy) { + this.price = price; + this.itemname = itemname; + this.isdrink = isdrink; + this.itempoints = itempoints; + this.itempointstobuy = itempointstobuy; + } + + // + public void processPurchase(customer customer, Scanner scanner) { + if (customer.getPointsearned() >= 100) { + System.out.println("You have enough points for a drink. Cool down with our new Honey tes water!"); + + int userchoice; + System.out.println("1. Use 100 points" + "\n" + "2. Maybe another time"); + userchoice = scanner.nextInt(); + switch (userchoice){ + case 1: + int newBalance = customer.getPointsearned() - 160; + customer.setPointsearned(newBalance); + + System.out.println("Thank you " + customer.getName() + ", your new rewards balance is " + newBalance); + break; + case 2: + break; + } + } + if (customer.getPointsearned() >= itempointstobuy) { + + System.out.println("Would you like to redeem your rewards points for this item?"); + System.out.println("1. Yes"); + System.out.println("2. No, I'll pay."); + + String choice = scanner.nextLine(); + + if (choice.equals("1")) { + int newBalance = customer.getPointsearned() - itempointstobuy; + customer.setPointsearned(newBalance); + System.out.println("Thank you, your new rewards balance is " + newBalance); + } else { + System.out.println("Ok, that'll be $" + price); + customer.setPointsearned(customer.getPointsearned() + itempoints); + + } + + } else { + System.out.println("Your total is $" + price); + customer.setPointsearned(customer.getPointsearned() + itempoints); + } + } + + public double getPrice() { + return price; + } + + public String getItemname() { + return itemname; + } +} \ No newline at end of file