i have a program that requires to keep track of all the itemsbought that have th
ID: 3617110 • Letter: I
Question
i have a program that requires to keep track of all the itemsboughtthat have there own unique parameters and they are of type Item
Ex)
Clothing-shit,price,quantity,weight
Groceries-cabbage,price,quantity,weight,perishable
Electronics -ps3,price,quantity,weight,fragile,location
i need help figuring out how to insert each item into a location ofthe array list
which is instantiated in the following way. also i have toprint out the whole list after adding all of the items. Anyhelp would be appreciated. Clothing, Groceries and Electronics allextend Item so i have set that up already. the only part neededwould be for the method insert only
ArrayList<Item> shoppingCart = new ArrayList<Item>;
public void insert (Item item) {
}
Explanation / Answer
Electronics e=new Electronics(" "," ");//hen you can insert item in the array list just calling itsadd method, like given below shopping Cart.add(c); shoping Cart.add(e);
}
//hen you can insert item in the array list just calling itsadd method, like given below shopping Cart.add(c); shoping Cart.add(e);
}
shoping Cart.add(e);
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.