Done, fuck that shit

This commit is contained in:
Logen Kain 2020-11-11 16:18:20 -05:00
parent b694a9e6e2
commit e820f29ed8
2 changed files with 18 additions and 8 deletions

View File

@ -24,7 +24,7 @@ public class ShoppingCart {
}
public void printNameDate (){
System.out.println(customerName + " Shopping Cart - "+ currentDate);
System.out.println(customerName + "'s Shopping Cart - "+ currentDate);
}
public void addItem(ItemToPurchase item){
@ -33,14 +33,14 @@ public class ShoppingCart {
public void removeItem(String itemName){
for (int i=0; i<cartItems.size(); i++){
System.out.println("itemName: |"+itemName+"|");
System.out.println("Test: " + cartItems.get(i).getName());
if (cartItems.get(i).getName().equals(itemName)){
cartItems.remove(i);
System.out.println();
return;
}
}
System.out.println("Item not found in cart. Nothing removed.");
System.out.println();
}
public void modifyItem(ItemToPurchase item){
for (int i=0; i<cartItems.size(); i++){
@ -58,6 +58,7 @@ public class ShoppingCart {
}
}
System.out.println("Item not found in cart. Nothing modified.");
System.out.println();
}
public int getNumItemsInCart(){
return cartItems.size();
@ -73,12 +74,17 @@ public class ShoppingCart {
public void printTotal(){
printNameDate();
System.out.println("Number of Items: " + cartItems.size());
int runningTotal = 0;
for (int i=0; i<cartItems.size(); i++){
runningTotal += cartItems.get(i).getQuantity();
}
System.out.println("Number of Items: " + runningTotal);
System.out.println();
if (cartItems.size() == 0){
System.out.println("SHOPPING CART IS EMPTY");
}
System.out.println();
for (int i=0; i<cartItems.size(); i++){
System.out.println(cartItems.get(i).getName() + " " +
@ -88,6 +94,7 @@ public class ShoppingCart {
cartItems.get(i).getQuantity()));
}
System.out.println("\nTotal: $" + getCostOfCart());
System.out.println();
}
public void printDescriptions(){
printNameDate();
@ -96,5 +103,6 @@ public class ShoppingCart {
for (int i=0; i<cartItems.size(); i++){
cartItems.get(i).printItemDescription();
}
System.out.println();
}
}

View File

@ -23,6 +23,7 @@ public class ShoppingCartManager {
while (userInput != 'q'){
userInput = scnr.next().charAt(0);
scnr.nextLine();
switch (userInput) {
case 'a': addItem(cart, scnr);
userInput = 0;
@ -58,7 +59,7 @@ public class ShoppingCartManager {
"i - Output items' descriptions\n"+
"o - Output shopping cart\n"+
"q - Quit");
System.out.println();
System.out.println("\nChoose an option:");
}
public static void addItem(ShoppingCart cart, Scanner scnr){
@ -70,7 +71,8 @@ public class ShoppingCartManager {
item.setDescription(scnr.nextLine());
System.out.println("Enter the item price:");
item.setPrice(scnr.nextInt());
System.out.println("Enter the item quantity");
System.out.println("Enter the item quantity:");
System.out.println();
item.setQuantity(scnr.nextInt());
cart.addItem(item);
}