I have a class called receipt
and one of the attributes is an array item[] items;
and I have a method addItem (string name , int quantity , double price)
. My question is how can I add these parameters to the array items[]
? And how do I check if the quantity is more than 0?
Whats the code? Is my question clear?
Hers is my code:
public boolean addItem(String name, int quantity,double price){
if(quantity <= 0){
System.out.println("Item wasnt added");
return false;}
else{
item [nItem++];//here is the problem
}
}