Reference no: EM132354075
Question
Form a class Item which has
- instance
variables: itemName, itemCost
- class variable: numberItems (gets increased every time a new Item is created)
- a default constructor that allows the user to set itemName and itemCost
( the default constructor sets itemName="apple" itemCost=2.49 if the user does not specify them)
- function to show() the item name and cost
- function to get() and set() the item name and cost
Form a list named groceryBag.
- Fill the list with several Item's such as eggs, milk, carrots, bread, apples, each with different price.
- use Item.numberItems to show how many items you have created.
- use a loop to calculate and show the totalCost for all the items in the bag