-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrocery_app.py
More file actions
55 lines (47 loc) · 1.58 KB
/
grocery_app.py
File metadata and controls
55 lines (47 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
class ShoppingList(object):
def __init__(self,title,description):
self.title = title
self.description = description
self.grocery_items = []
def addItem(self,*args):
self.args = args
for arg in args:
if arg not in self.grocery_items:
self.grocery_items.append(arg)
def printList(self):
print "\b"
print self.title + " list: " + self.description
for grocery_item in self.grocery_items:
print grocery_item.title
print "\b"
class GroceryItem(object):
def __init__(self,title):
self.title = title
fiesta = ShoppingList('Fiesta','What to get at Fiesta Mart')
walmart = ShoppingList('Walmart','What to get at Walmart')
sams_club = ShoppingList("Sam's Club","What to get at Sam's Club")
costco = ShoppingList('Costco','What to get at Costco')
randalls = ShoppingList('Randalls','What to get at Randalls')
milk = GroceryItem('Milk')
soda = GroceryItem('Soda')
fish = GroceryItem('Fish')
paper = GroceryItem('Paper')
napkins = GroceryItem('Napkins')
plate = GroceryItem('Plate')
chips = GroceryItem('Chips')
beef = GroceryItem('Beef')
eggs = GroceryItem('Eggs')
sugar = GroceryItem('Sugar')
salt = GroceryItem('Salt')
pepper = GroceryItem('Pepper')
honey = GroceryItem('Honey')
tv = GroceryItem('Television')
computer = GroceryItem('Computer')
fiesta.addItem(milk,soda,fish)
walmart.addItem(paper,napkins,plate,chips)
sams_club.addItem(beef,eggs,sugar,salt,pepper,honey)
costco.addItem(tv,computer)
fiesta.printList()
walmart.printList()
sams_club.printList()
costco.printList()