1. Engineering
  2. Computer Science
  3. part 2 grocerylist 20 points you must implement the following...

Question: part 2 grocerylist 20 points you must implement the following...

Question details

Part 2: GroceryList (20 points): You must implement the following methods of the GroceryList class. The constructor, addGroceryltem, getltems, findItemsByCategory, getTotalCost, multipyAllltemsCount, multipyltemCountByCategory andstrYou may not change the method definitions. See the doc strings in the file for information and see the usage below for details. >>>gl-GroceryList) >>> gi-GroceryItem(milk,1.99,2, dairy >>> gl.addGroceryItem (gi) >>>gi-GroceryItem (eggs,1.59,1, dairy >>> gl.addGroceryItem (gi) >>>gi-GroceryItem(1 pound ground boef,5.99,1, meat) >>> gl.addGroceryItem (gi) >>> gi-GroceryItem (bananas,2.99,2, Eruit) >>>gl.addGroceryItem (gi) >>> gi-Groceryitem(strawberries.3.99,2, fruit >>> gl.addGroceryItem (gi) s>> gi-Groceryitem(lettuce .0.99,5,vegetables ) >>> gl.addGroceryItem (gi) >>> print (str (gl) ) milk:1.99:2:dairy eggs:1.59:1:dairy 1 pound ground beef:5.99:1:meat bananas:2.99:2:fruit strawberries:3.99:2:fruit lettuce:0.99:5:vegetables >>> gl.multiplyitemCountByCategoryEruit,3) True >>> print (str (gl)) milk:1.99:2:dairy ggs:1.59:1:dairy 1 pound ground beef:5.99:1:meat bananas:2.99:6:fruit strawberries:3.99:6:fruit lettuce:0.99:5:vegetables >>>gi.multiplyAllitomsCount (2) True >>> print (str (gl) milk:1.99:4idairy eggs:1.59:2idalry 1 pound ground beef:5.99:2:meat bananas:2.99:12:fruit strawberries:3.99:12:fruit >>>gl.getTotalcost O 116.70
>>> fruits-gl.findItemsByCategory (fruit) >>> type (fruits) <class list > >>> for f in fruits: print (str (f) ) bananas:2.99:12:fruit strawberries : 3·99: 12: fruit >>> allitems = gl.getItems() >>>type (allItems) <class list> >>> for i in allitems: print (str (i)) milk: 1.99:4:dairy eggs: 1.59:2:dairy 1 pound ground beef : 5 99 : 2 : meat bananas:2.99:12: fruit strawberries: 3.99:12: fruit lettuce:0.99: 10:vegetables
Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution