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..de5c651 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..3729cc3
--- /dev/null
+++ b/src/main/java/org/codedifferently/CoffeeItem.java
@@ -0,0 +1,30 @@
+package org.codedifferently;
+
+public class CoffeeItem {
+ private String itemName; //name of the item
+ private double price; //price of the item
+
+ //constructor for the item
+ CoffeeItem(String itemName, double price){
+ this.itemName = itemName;
+ this.price = price;
+ }
+
+ //setters and getters for the coffee item
+ 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;
+ }
+
+} // ends CoffeeItem class
diff --git a/src/main/java/org/codedifferently/Customer.java b/src/main/java/org/codedifferently/Customer.java
new file mode 100644
index 0000000..9b80c25
--- /dev/null
+++ b/src/main/java/org/codedifferently/Customer.java
@@ -0,0 +1,50 @@
+package org.codedifferently;
+
+public class Customer {
+ private String name; //name of the customer
+ private String email; //email for the customer
+ private int drinksPurchased; //number of drinks the customer purchased
+ Customer(){
+ }
+
+ //Constructor for the customer object
+ Customer(String name, String email, int drinksPurchased){
+ this.name = name;
+ this.email = email;
+ this.drinksPurchased = drinksPurchased;
+ }
+
+ //setters and getters for the instance variables
+ public String getName(){
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setPhoneNumber(String email) {
+ this.email = email;
+ }
+
+ public int getDrinksPurchased() {
+ return drinksPurchased;
+ }
+
+ public void setDrinksPurchased(int drinksPurchased) {
+ this.drinksPurchased = drinksPurchased;
+ }
+
+
+ //checks to see if the customer is eligible for a reward
+ public boolean isEligibleForReward(){
+ if(drinksPurchased >= 5){
+ return true;
+ }
+ return false;
+ }
+}// ends Customer class
diff --git a/src/main/java/org/codedifferently/Main.java b/src/main/java/org/codedifferently/Main.java
index 435139b..a6fcc7d 100644
--- a/src/main/java/org/codedifferently/Main.java
+++ b/src/main/java/org/codedifferently/Main.java
@@ -1,17 +1,82 @@
package org.codedifferently;
-
+import java.util.*;
//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);
- }
+ Scanner input = new Scanner(System.in); //scanner object
+
+ //vars for the customer, the customer's order, boolean var for the menu checkout, and the receipt object
+ Customer customer1 = new Customer("Bryant", "bob@gmail.com",0);
+ boolean checkout = false;
+ String customerOrder ="";
+ Receipt receipt = new Receipt();
+
+ //Prompts the user for their order, displays the menu, and displays their receipt
+ do {
+ System.out.println("Welcome " + customer1.getName() + " to Triple Cs!");
+ System.out.println("*************************************");
+ System.out.println("Our Menu:");
+ System.out.println("1) Coffee $10.00");
+ System.out.println("2) Tea $5.50");
+ System.out.println("3) Lemonade $12.00");
+ System.out.println("4) Water $17.50");
+ System.out.println("5) Soda $10.50");
+ System.out.println("6) Milkshake $8.00");
+ System.out.println();
+ System.out.println("Please enter the number(s) of the drink(s) you would like to order.");
+ System.out.println("Separate multiple items with a comma (e.g., 1,3,5).");
+
+ boolean validOrder = false;
+
+ while (!validOrder) {
+
+ customerOrder = input.nextLine();
+
+ // checks if input contains ONLY digits 1-6 and commas
+ if (customerOrder.matches("[1-6,]+")) {
+ validOrder = true;
+ } else {
+ System.out.println("Invalid selection. Please enter numbers 1-6 only.");
+ System.out.println("Try again:");
+ }
+ }
+
+ System.out.println("*************************************");
+ receipt.createCustomerOrder(customer1, customerOrder);
+ System.out.println(receipt.getFullReceipt());
+ System.out.println("*************************************");
+ receipt.checkRewards(customer1, receipt.getTotalAmt());
+ System.out.println("*************************************");
+
+ //prompts the user to check out
+ System.out.println("Are you ready to checkout? (y/n)");
+
+ boolean validAnswer = false;
+ String choice = "";
+
+ while (!validAnswer) {
+
+ choice = input.nextLine().toLowerCase();
+
+ /*this chunk of code checks to see if the user's choice is a valid input
+ and if they want to continue shopping or not*/
+ if (choice.matches("[yn]")) {
+ validAnswer = true;
+
+ if (choice.equals("y")) {
+ System.out.println("Goodbye, have a great day!");
+ checkout = true;
+ }
+
+ } else {
+ System.out.println("Invalid selection. Please enter y or n.");
+ System.out.println("Try again:");
+ }
+ }
+
+ } while(!checkout);
}
+
+
}
\ No newline at end of file
diff --git a/src/main/java/org/codedifferently/Receipt.java b/src/main/java/org/codedifferently/Receipt.java
new file mode 100644
index 0000000..3a60eea
--- /dev/null
+++ b/src/main/java/org/codedifferently/Receipt.java
@@ -0,0 +1,103 @@
+package org.codedifferently;
+
+public class Receipt
+{
+ private double totalAmt; //customer's total bill amount
+ private StringBuilder orderSummary = new StringBuilder("You ordered:\n"); //creates the customer's receipt
+
+ //setters and getters for the instance variables
+ public void setTotalAmt(double totalAmt) {
+ this.totalAmt = totalAmt;
+ }
+
+ public double getTotalAmt() {
+ return totalAmt;
+ }
+
+ //creates the receipt for the customer by creating coffeeItem objects
+ public StringBuilder createCustomerOrder(Customer customer, String customerOrder){
+ int drinkCounter = 0;
+ for (int i=0; i< customerOrder.length(); i++) {
+
+ switch (Character.getNumericValue(customerOrder.charAt(i))) {
+ case 1:
+ CoffeeItem item1 = new CoffeeItem("Coffee", 10.00);
+ orderSummary.append(
+ String.format("%s $%.2f%n", item1.getItemName(), item1.getPrice())
+ );
+ drinkCounter++;
+ totalAmt += item1.getPrice();
+ break;
+
+ case 2:
+ CoffeeItem item2 = new CoffeeItem("Tea", 5.50);
+ orderSummary.append(
+ String.format("%s $%.2f%n", item2.getItemName(), item2.getPrice())
+ );
+ drinkCounter++;
+ totalAmt += item2.getPrice();
+ break;
+
+ case 3:
+ CoffeeItem item3 = new CoffeeItem("Lemonade", 12.00);
+ orderSummary.append(
+ String.format("%s $%.2f%n", item3.getItemName(), item3.getPrice())
+ );
+ drinkCounter++;
+ totalAmt += item3.getPrice();
+ break;
+
+ case 4:
+ CoffeeItem item4 = new CoffeeItem("Water", 17.50);
+ orderSummary.append(
+ String.format("%s $%.2f%n", item4.getItemName(), item4.getPrice())
+ );
+ drinkCounter++;
+ totalAmt += item4.getPrice();
+ break;
+
+ case 5:
+ CoffeeItem item5 = new CoffeeItem("Soda", 10.50);
+ orderSummary.append(
+ String.format("%s $%.2f%n", item5.getItemName(), item5.getPrice())
+ );
+ drinkCounter++;
+ totalAmt += item5.getPrice();
+ break;
+
+ case 6:
+ CoffeeItem item6 = new CoffeeItem("Milkshake", 8.00);
+ orderSummary.append(
+ String.format("%s $%.2f%n", item6.getItemName(), item6.getPrice())
+ );
+ drinkCounter++;
+ totalAmt += item6.getPrice();
+ break;
+ }
+ }
+
+ customer.setDrinksPurchased(customer.getDrinksPurchased() + drinkCounter);
+
+ return orderSummary;
+ }
+
+ //returns the customer's receipt '
+ public String getFullReceipt() {
+ return orderSummary.toString() + String.format("%nYour total is $%.2f", totalAmt);
+ }
+
+ //checks to see if the customer has earned any awards and displays a message to the user
+ public void checkRewards(Customer customer, double total){
+ if (customer.isEligibleForReward()) {
+ System.out.println("Congrats, You are eligible for a reward!\nYour next drink is free!");
+ }
+ if (total > 20.00){
+ System.out.println("You have gained bonus points on your account.");
+ }
+
+ if(customer.getDrinksPurchased() < 5){
+ System.out.println("Drinks towards reward: " + (5 - customer.getDrinksPurchased()));
+ }
+
+ }
+}