public class Shopping {
public static void main(String args[]){
System.out.println("How many carts do you want? ");
System.out.println("Please estimate number of item you want in this Cart! ");
}
}
import java.util.ArrayList;
public class Cart {
ArrayList<Item> cart1= new ArrayList<Item>();
}
I am trying to add three variables in "Item" class in the "cart1" (in Cart class) arraylist in one index without changing the data type (if this is possible). How can i do that?
public class Item {
String name;
Integer price;
Integer quantity;
public Item(String n, int p, int q){
name = n;
price = p;
quantity = q;
}
public String getName(){
return name;
}
public int getPrice(){
return price;
}
public int getQuantity(){
return quantity;
}
}

New Topic/Question
Reply




MultiQuote





|