I have to make a program that simulates a shopping cart, I have it done, it's just that the shopping cart wont print. Please help me in fixing this, this is due for me tomorrow and is worth 40% of this chapter grade.
The files are attached below. The main one is ShoppingSim.java
Alishaikh -3 Light Poster
Recommended Answers
Jump to Postjust post the code you want us to review here, not in attachment.
as far as I understand from your description, you've got an array of some sort, containing objects of a class (for instance, Product)to print those: iterate over the elements of the array, and print each …
Jump to PostOh, I think it's printing the cart just fine.
The problem is that your menu choice handler creates a new cart every time it's called.
Jump to PostI only see one logical place for it, given the structure of your ShoppingSim driver program. Where do you think it should go? Where would it make sense to create a new cart?
Jump to PostYou shouldn't have any problems doing that. The API for ArrayList is pretty straightforward. You don't have to manage the size of it yourself and you have methods to add(), get(), and remove() …
All 13 Replies
BestJewSinceJC 700 Posting Maven
stultuske 1,116 Posting Maven Featured Poster
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
Alishaikh -3 Light Poster
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
Alishaikh -3 Light Poster
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
Alishaikh -3 Light Poster
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
Alishaikh -3 Light Poster
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
Alishaikh -3 Light Poster
Alishaikh -3 Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.