Done, fuck that shit
This commit is contained in:
parent
b694a9e6e2
commit
e820f29ed8
@ -24,7 +24,7 @@ public class ShoppingCart {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void printNameDate (){
|
public void printNameDate (){
|
||||||
System.out.println(customerName + " Shopping Cart - "+ currentDate);
|
System.out.println(customerName + "'s Shopping Cart - "+ currentDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addItem(ItemToPurchase item){
|
public void addItem(ItemToPurchase item){
|
||||||
@ -33,14 +33,14 @@ public class ShoppingCart {
|
|||||||
|
|
||||||
public void removeItem(String itemName){
|
public void removeItem(String itemName){
|
||||||
for (int i=0; i<cartItems.size(); i++){
|
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)){
|
if (cartItems.get(i).getName().equals(itemName)){
|
||||||
cartItems.remove(i);
|
cartItems.remove(i);
|
||||||
|
System.out.println();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.out.println("Item not found in cart. Nothing removed.");
|
System.out.println("Item not found in cart. Nothing removed.");
|
||||||
|
System.out.println();
|
||||||
}
|
}
|
||||||
public void modifyItem(ItemToPurchase item){
|
public void modifyItem(ItemToPurchase item){
|
||||||
for (int i=0; i<cartItems.size(); i++){
|
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("Item not found in cart. Nothing modified.");
|
||||||
|
System.out.println();
|
||||||
}
|
}
|
||||||
public int getNumItemsInCart(){
|
public int getNumItemsInCart(){
|
||||||
return cartItems.size();
|
return cartItems.size();
|
||||||
@ -73,12 +74,17 @@ public class ShoppingCart {
|
|||||||
|
|
||||||
public void printTotal(){
|
public void printTotal(){
|
||||||
printNameDate();
|
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();
|
System.out.println();
|
||||||
|
|
||||||
if (cartItems.size() == 0){
|
if (cartItems.size() == 0){
|
||||||
System.out.println("SHOPPING CART IS EMPTY");
|
System.out.println("SHOPPING CART IS EMPTY");
|
||||||
}
|
}
|
||||||
System.out.println();
|
|
||||||
|
|
||||||
for (int i=0; i<cartItems.size(); i++){
|
for (int i=0; i<cartItems.size(); i++){
|
||||||
System.out.println(cartItems.get(i).getName() + " " +
|
System.out.println(cartItems.get(i).getName() + " " +
|
||||||
@ -88,13 +94,15 @@ public class ShoppingCart {
|
|||||||
cartItems.get(i).getQuantity()));
|
cartItems.get(i).getQuantity()));
|
||||||
}
|
}
|
||||||
System.out.println("\nTotal: $" + getCostOfCart());
|
System.out.println("\nTotal: $" + getCostOfCart());
|
||||||
|
System.out.println();
|
||||||
}
|
}
|
||||||
public void printDescriptions(){
|
public void printDescriptions(){
|
||||||
printNameDate();
|
printNameDate();
|
||||||
System.out.println("\n Item Descriptions");
|
System.out.println("\nItem Descriptions");
|
||||||
|
|
||||||
for (int i=0; i<cartItems.size(); i++){
|
for (int i=0; i<cartItems.size(); i++){
|
||||||
cartItems.get(i).printItemDescription();
|
cartItems.get(i).printItemDescription();
|
||||||
}
|
}
|
||||||
|
System.out.println();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ public class ShoppingCartManager {
|
|||||||
|
|
||||||
while (userInput != 'q'){
|
while (userInput != 'q'){
|
||||||
userInput = scnr.next().charAt(0);
|
userInput = scnr.next().charAt(0);
|
||||||
|
scnr.nextLine();
|
||||||
switch (userInput) {
|
switch (userInput) {
|
||||||
case 'a': addItem(cart, scnr);
|
case 'a': addItem(cart, scnr);
|
||||||
userInput = 0;
|
userInput = 0;
|
||||||
@ -58,7 +59,7 @@ public class ShoppingCartManager {
|
|||||||
"i - Output items' descriptions\n"+
|
"i - Output items' descriptions\n"+
|
||||||
"o - Output shopping cart\n"+
|
"o - Output shopping cart\n"+
|
||||||
"q - Quit");
|
"q - Quit");
|
||||||
System.out.println();
|
System.out.println("\nChoose an option:");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addItem(ShoppingCart cart, Scanner scnr){
|
public static void addItem(ShoppingCart cart, Scanner scnr){
|
||||||
@ -70,7 +71,8 @@ public class ShoppingCartManager {
|
|||||||
item.setDescription(scnr.nextLine());
|
item.setDescription(scnr.nextLine());
|
||||||
System.out.println("Enter the item price:");
|
System.out.println("Enter the item price:");
|
||||||
item.setPrice(scnr.nextInt());
|
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());
|
item.setQuantity(scnr.nextInt());
|
||||||
cart.addItem(item);
|
cart.addItem(item);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user