what am i going to do? we are tasked to create a shopping cart. Product list should be stored in a text file. I have it already, the thing is when the user would buy a certain quantity of a certain product, let say

Product list:

item# price quantity
pencil $5.00 10

Mr. A bought 2 pencils totaling $10.00 to pay.

how do i get the quantity of the product in the list to change?

pls help..

9 Years
Discussion Span
Last Post by stultuske

how do i get the quantity of the product in the list to change?

by thinking of the basic principles of OO-programming and using getters and setters, or a method that takes a variable with the number of products that should be added to the present quantity, and add it.

like this:

public void increaseQuantity(int numberToAdd){
  this.quantity += numberToAdd;

for the rest of your code... please do not think we will deliver a ready-to-go project. this is your assignment, not ours. you haven't shown any effort or code of your own, and either I misinterpretated your question, or you're in way over your head. if you don't understand basic OO-programming, don't be surprised if you can't finish this assignment

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.