diff --git a/.DS_Store b/.DS_Store
index a70ee6b..d6f6f33 100644
Binary files a/.DS_Store and b/.DS_Store differ
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
index e7cd972..b2320b5 100644
--- a/.idea/encodings.xml
+++ b/.idea/encodings.xml
@@ -1,6 +1,8 @@
+
+
diff --git a/.idea/misc.xml b/.idea/misc.xml
index b28c0fb..f252195 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -5,10 +5,11 @@
-
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index 36361c6..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index 8306744..35eb1dd 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -2,6 +2,5 @@
-
\ No newline at end of file
diff --git a/README.md b/README.md
index 9c12bdd..2362803 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,4 @@
+[](https://classroom.github.com/a/6tlCTWq0)
# 🧾 Mystery Receipt Generator (Java CLI Project)
## Overview
diff --git a/pom.xml b/pom.xml
index 24314b9..6a72441 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,8 +9,8 @@
1.0-SNAPSHOT
- 25
- 25
+ 21
+ 21
UTF-8
diff --git a/src/main/java/org/codedifferently/Main.java b/src/main/java/org/codedifferently/Main.java
deleted file mode 100644
index 8a571aa..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 {
- static void main() {
- //TIP Press with your caret at the highlighted text
- // to see how IntelliJ IDEA suggests fixing it.
- IO.println(String.format("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 .
- IO.println("i = " + i);
- }
- }
-}
diff --git a/src/main/java/org/codedifferently/ReceiptApp/ConsolePrint.java b/src/main/java/org/codedifferently/ReceiptApp/ConsolePrint.java
new file mode 100644
index 0000000..0480bef
--- /dev/null
+++ b/src/main/java/org/codedifferently/ReceiptApp/ConsolePrint.java
@@ -0,0 +1,66 @@
+package org.codedifferently.ReceiptApp;
+
+//print console output
+public class ConsolePrint {
+ public void printResults(int visitID, String fullReceiptCode, StoreItem item1, StoreItem item2, StoreItem item3, double subTotal, double taxRate, boolean isDiscount, double discountRate, double fee, boolean isValidCoupon, String couponCode, int discountVal, double finalTotal, double budget){
+
+ //instantiate object for price calculation methods
+ PriceCalculations calculatePrice = new PriceCalculations();
+
+ System.out.println("--------- Welcome to Alex's Electronics ----------");
+ System.out.println("Visit ID: " + visitID);
+ System.out.println("Receipt Code: " + fullReceiptCode);
+ //System.out.println(item1.getName() + ": $" + item1.getPrice());
+ System.out.println(item1.getName() + ": $" + Math.round(item1.getPrice() * 100.0) / 100.0);
+ // System.out.println(item2.getName() + ": $" + item2.getPrice());
+ System.out.println(item2.getName() + ": $" + Math.round(item2.getPrice() * 100.0) / 100.0);
+ //System.out.println(item3.getName() + ": $" + item3.getPrice());
+ System.out.println(item3.getName() + ": $" + Math.round(item3.getPrice() * 100.0) / 100.0);
+ //System.out.println("Subtotal: $" + subTotal);
+ System.out.println("Subtotal: $" + Math.round(subTotal * 100.0) / 100.0);
+ //System.out.println("Sales Tax: " + taxRate +"%");
+ System.out.println("Sales Tax: " + Math.round(taxRate * 100.0) / 100.0 + "%");
+
+
+ if(isDiscount){
+ System.out.println("--------- You received a lucky discount! ---------");
+ //System.out.println("Lucky Discount: " + discountRate + "%");
+ System.out.println("Lucky Discount: " + (Math.round(discountRate * 100.0)/100.0) + "%");
+
+ subTotal = calculatePrice.extraValues(subTotal, true, 0, discountRate);
+ //System.out.println("New Subtotal: $" + subTotal);
+ System.out.println("New Subtotal: $" + (Math.round(subTotal*100.0)/100.0));
+
+ //System.out.println("You will receive: " + subTotal*(discountRate/100) + " off");
+
+ }else{
+ System.out.println("--------- A small processing fee was added to your order---------");
+ //System.out.println("Processing Fee: " + "$" + fee);
+ System.out.println("Processing Fee: " + "$" + (Math.round(fee * 100.0)/100.0));
+
+ subTotal = calculatePrice.extraValues(subTotal, false, fee, 0);
+ //System.out.println("New Subtotal: $" + subTotal);
+ System.out.println("New Subtotal: $" + (Math.round(subTotal*100.0)/100.0));
+
+ }
+ if(isValidCoupon){
+ System.out.println("---------- Coupon Code *" + couponCode.toUpperCase() + "* Accepted ----------");
+ //System.out.println("Discount: " + discountVal + "%");
+ System.out.println("Discount: " + (Math.round(discountVal * 100.0)/100.0) + "%");
+
+ subTotal = calculatePrice.extraValues(subTotal, true, 0, discountVal);
+ //System.out.println("New Subtotal: $" + subTotal);
+ System.out.println("New Subtotal: $" + (Math.round(subTotal*100.0)/100.0));
+
+ //System.out.println("Your will receive: " + subTotal*(discountVal/100) + " off");
+ }
+ System.out.println("Final Total + Tax: $" + Math.round(finalTotal*100.0)/100.0);
+ if(budget - finalTotal >= 0){
+ System.out.println("You have $" + Math.round((budget-finalTotal)*100.0)/100.0 + " remaining in your budget");
+ }else{
+ System.out.println("You need $" + Math.round(Math.abs(budget-finalTotal)*100.0)/100.0 + " more in your budget to complete this transaction");
+ }
+ //whether user can afford with their budget or if they are short
+
+ }
+}
diff --git a/src/main/java/org/codedifferently/ReceiptApp/CouponChecker.java b/src/main/java/org/codedifferently/ReceiptApp/CouponChecker.java
new file mode 100644
index 0000000..bc7b516
--- /dev/null
+++ b/src/main/java/org/codedifferently/ReceiptApp/CouponChecker.java
@@ -0,0 +1,47 @@
+package org.codedifferently.ReceiptApp;
+
+public class CouponChecker {
+
+ //check if a coupon is valid
+ public boolean couponCheck(String[] acceptedCoupons, String providedCoupon){
+ boolean isValidCoupon = false;
+ for (int i=0; i< acceptedCoupons.length; i++){
+ if(acceptedCoupons[i].equals(providedCoupon.toUpperCase())){
+ isValidCoupon = true;
+ //discountVal = discountVal * (i+1);
+ return isValidCoupon;
+
+ }
+ //don't get a discount
+ }
+ return false;
+ }
+
+
+ //set discount value of coupon
+ public int discountRate(boolean isCoupon, String[] acceptedCoupons, String providedCoupon){
+ int discountVal = 25;
+ if (isCoupon){
+ for (int i=0; i< acceptedCoupons.length; i++){
+ if(acceptedCoupons[i].equals(providedCoupon.toUpperCase())){
+
+ discountVal = discountVal * (i+1);
+ return discountVal;
+ }
+ //don't get a discount
+ }
+ }
+ return 0;
+ }
+
+ //apply coupon discount to final pricing
+ public double applyCoupon(boolean isValidCoupon, double subTotal, int discountVal){
+ if (isValidCoupon){
+ subTotal = subTotal - (subTotal*discountVal/100);
+ return subTotal;
+ }
+ else{
+ return subTotal;
+ }
+ }
+}
diff --git a/src/main/java/org/codedifferently/ReceiptApp/Main.java b/src/main/java/org/codedifferently/ReceiptApp/Main.java
new file mode 100644
index 0000000..6a881f3
--- /dev/null
+++ b/src/main/java/org/codedifferently/ReceiptApp/Main.java
@@ -0,0 +1,80 @@
+package org.codedifferently.ReceiptApp;
+
+import java.util.Scanner;
+
+//TIP To Run code, press or
+// click the icon in the gutter.
+public class Main {
+ public static void main(String[] args) {
+
+ //these are the accepted coupon codes
+ String[] couponCodes = {"25OFF", "50OFF", "75OFF", "100OFF"};
+
+ //get username
+ System.out.println("Please enter your username: ");
+ Scanner scanner = new Scanner(System.in);
+ String username = scanner.next();
+
+ //get budget
+ System.out.println("Please enter your budget: ");
+ double budget = scanner.nextDouble();
+
+ //get coupon code
+ System.out.println("Please enter your coupon code: ");
+ String couponCode = scanner.next();
+
+ //instantiate objects so we can use their methods
+ RandomGenerations randomItem = new RandomGenerations();
+ PriceCalculations calculatePrice = new PriceCalculations();
+ CouponChecker coupon = new CouponChecker();
+ ConsolePrint output = new ConsolePrint();
+
+
+ //generate random values for discount, fee and rates
+ boolean isDiscount = randomItem.discount();
+ double fee = randomItem.fee();
+ double taxRate = randomItem.tax();
+ double discountRate = randomItem.tax();
+
+ //generate random item IDs
+ int itemSelectionOne = randomItem.item();
+ int itemSelectionTwo = randomItem.item();
+ int itemSelectionThree = randomItem.item();
+
+ //generate random items mapped from ID's
+ StoreItem item1 = new StoreItem(itemSelectionOne, randomItem.prices());
+ StoreItem item2 = new StoreItem(itemSelectionTwo, randomItem.prices());
+ StoreItem item3 = new StoreItem(itemSelectionThree, randomItem.prices());
+
+ //store item prices in an array to use with subtotal method
+ double[] itemPrices = {item1.getPrice(), item2.getPrice(), item3.getPrice()};
+
+ //calculate sum of item prices
+ double subTotal = calculatePrice.subtotal(itemPrices);
+
+ //calculate price after incorporating fee/lucky discount, tax, etc..
+ double subFinalTotal = calculatePrice.finalTotal(subTotal, isDiscount, fee, taxRate, discountRate);
+
+ //generate random visitID
+ int visitID = randomItem.visitIDGen();
+
+ //generate receiptCode
+ String fullReceiptCode = randomItem.receiptCode(username, visitID);
+
+ //check whether coupon is valid
+ boolean isValidCoupon = coupon.couponCheck(couponCodes, couponCode);
+
+ //if coupon is valid, assigns the discount value
+ int discountVal = coupon.discountRate(isValidCoupon, couponCodes, couponCode);
+
+ //calculate final total after all coupons, taxes, fees, etc. applied
+ double finalTotal = coupon.applyCoupon(isValidCoupon, subFinalTotal, discountVal);
+
+ //moved all print statements and print logic into a class called console print
+ //method print results takes all of these values we found and prints formatted info to console
+ output.printResults(visitID, fullReceiptCode, item1, item2,
+ item3, subTotal, taxRate, isDiscount, discountRate,
+ fee, isValidCoupon, couponCode, discountVal, finalTotal, budget);
+
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/codedifferently/ReceiptApp/PriceCalculations.java b/src/main/java/org/codedifferently/ReceiptApp/PriceCalculations.java
new file mode 100644
index 0000000..34ce6ce
--- /dev/null
+++ b/src/main/java/org/codedifferently/ReceiptApp/PriceCalculations.java
@@ -0,0 +1,41 @@
+package org.codedifferently.ReceiptApp;
+
+public class PriceCalculations {
+
+ //sum list of doubles
+ public double subtotal(double[] prices){
+ double subtotal = 0.0;
+ for (int i=0; i= discountBottomThresh && idCheck <= discountTopThreshold) {
+ return true;
+ } else {
+ return false;
+ }
+
+ }
+
+ //merge random visitID code into receiptCode
+ public String receiptCode(String username, int visitID){
+
+ String receiptCode;
+ if (username.length() < 5){
+ receiptCode = username.toUpperCase();
+ }else{
+ receiptCode = username.substring(0, 4).toUpperCase();
+ }
+
+ String fullReceiptCode = receiptCode + "-" + visitID;
+
+ return fullReceiptCode;
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/org/codedifferently/ReceiptApp/StoreItem.java b/src/main/java/org/codedifferently/ReceiptApp/StoreItem.java
new file mode 100644
index 0000000..6f7c63e
--- /dev/null
+++ b/src/main/java/org/codedifferently/ReceiptApp/StoreItem.java
@@ -0,0 +1,59 @@
+package org.codedifferently.ReceiptApp;
+
+public class StoreItem{
+
+ //instance variables
+ String name;
+ double price;
+ int itemID;
+
+ public StoreItem(int itemID, double price){
+ this.price = price;
+ this.itemID = itemID;
+ switch (this.itemID){
+ case 0:
+ this.name = "TV";
+ break;
+ case 1:
+ this.name = "iPhone";
+ break;
+ case 2:
+ this.name = "PC";
+ break;
+ case 3:
+ this.name = "Macbook";
+ break;
+ case 4:
+ this.name = "ipad";
+ break;
+ case 5:
+ this.name = "Surround Sound System";
+ break;
+ case 6:
+ this.name = "PS5";
+ break;
+ case 7:
+ this.name = "Meta Glasses";
+ break;
+ case 8:
+ this.name = "Google Pixel";
+ break;
+ case 9:
+ this.name = "Xbox Series X";
+ break;
+ default:
+ this.name = "TV";
+
+ }
+
+ }
+
+ public String getName(){
+ return name;
+ }
+
+ public double getPrice(){
+ return price;
+ }
+
+}