Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

Java - Simulate an online shopping cart

tt95588n
tt95588n 


Instructions are in the word document. The file CartItem.java is already complete. All of the work needs to be done in the shopping.java file, but you do need both files open in order for it to work. Thanks for your help ! Use CartItem (2).java instead of CartItem.java Attachments Tags Clarifications

Answers

Java - Simulate an online shopping cart - Solution

dickersonka
dickersonka 



Attached is the Java - Simulate an online shopping cart solution including source and comments.

You do need to update the CartItem class. This class needed to override equals(Object item) not equals(CartItem item).
Attachments
ShoppingCart.zip (1 K) Download
Preview
price = inPrice; } public boolean equals(Object o) { if(o == null){ return false; } if(o instanceof CartItem){ CartItem item = (CartItem)o; if (this.product.equalsIgnoreCase(item.product)) return true; } return false; }

Preview
In this program you will replicate an online shopping * cart. You will use the ArrayList class to hold the * items in your shopping cart. * You will use the CartItem class to represent items in * your shopping cart. * In this driver program you will do the

Screenshots
Purchase Answer

Shopping Cart Solution

mariobeka
mariobeka 



Here goes the solution for your question. Attachments
Shopping.java (5 K) Download Preview
"); product = scan.next(); System.out.print("\nEnter quantity: "); quantity = scan.nextInt(); System.out.print("\nEnter price: "); price = scan.nextDouble(); item = new CartItem(product, quantity, price); shoppingCart.add(item); System.out.println("New item was added to your Shopping Cart."); break; case 2: //remove from the list System.out.print("Enter product name: "); product = scan.next(); Iterator<CartItem> it = shoppingCart.iterator(); while

CartItem.java (1 K) Download Preview
double inPrice) { product = inProduct; quantity = inQuant; price = inPrice; } //getter setter public methods for each instance data public String getProduct() { return product; } public int getQuantity() { return quantity; }

Screenshots
Purchase Answer