1. Engineering
  2. Computer Science
  3. part 2 grocery list 20 points you must implement the...

Question: part 2 grocery list 20 points you must implement the...

Question details

Part 2: Grocery List (20 points): You must implement the following methods of the GroceryList elass. The constructor. addGroceryltem, getltems, findltemsByCategory, getTotalCost, multipy AlltemsCount, multipyltemCountByCategory and str You may not change the method definitions. See the doc strings in the file for information and see the usage below for details >>> g1-GroceryList) >>> gi-GroceryItem(milk 1.99,2, dairy) >>> gl.addGroceryitem (gi) >>> gi-GroceryItem( 1.59,1, dairy) >>> gl.addGroceryItem(gi) >>> gi-GroceryItem (1 pound ground beef .5.99,1,meat) >> gl.addGroceryitem(gi) > gi Groceryitem(bananas ,2.99,2,fruit:) >>gi.addGzoceryitem(gi) >>>gi Groceryitenstzavbezzias,3.99,2, trust) >> gl.addGzoceryitem (gi) 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.multiplyI temCountByCategory(Eruit,3) True >>> print (str (g1)) miik:1.99:2:dairy eggs: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 >>> gl.multiplyA11itemscount (2) True >>> print (str (g1)) milk:i-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 >>>g1.getTotalCost (1 116.70
>>> fruits-gl.findItemsBycategory(fruit) >>> type (fruits) <class lists >>> for f in fruits: print (str (f)) bananas:2.99:12: fruit strawberries:3.99:12: fruit >>> allitems = gl.ge t 1 tems () >>> type (al1Items) <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:o.99: 10:vegetables
Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution