-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathtestScript.py
More file actions
90 lines (69 loc) · 1.98 KB
/
testScript.py
File metadata and controls
90 lines (69 loc) · 1.98 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import random
class Ingredient():
def __init__(self, name, price=0.75):
self.name = name
self.price = price
class Condiment(Ingredient):
price = 0.0
def __init__(self, name):
self.name = name
ingredients = [
Condiment("ketchup"),
Condiment("mustard"),
Ingredient("lettuce", 0.25),
Ingredient("onion", 0.25),
Ingredient("extraLettuce", 0.25),
Ingredient("truffles", 10.25),
Ingredient("gold leaf", 12),
Ingredient("foi gras", 30),
Ingredient("gummy bears", 0.99),
]
def getIngredientByName(name):
for ingredient in ingredients:
if ingredient.name == name:
return ingredient
newIngredient = Ingredient(name)
ingredients.append(newIngredient)
return newIngredient
class Sandwich():
basePrice = 2.0
def __init__(self, crust="bread"):
self.crust = crust
self.ingredients = []
def printInstructions(self):
print ("add " + self.crust)
self.printIngredients()
print ("add " + self.crust)
def getPrice(self):
price = self.basePrice
for ingredient in ingredients:
price = price + ingredient.price
return price
def addIngredient(self, ingredient):
self.ingredients.append(ingredient)
def addIngredients(self, ingredients):
self.ingredients.extend(ingredients)
def printIngredients(self):
for ingredient in self.ingredients:
print(ingredient.name)
def getUserBread():
print("GIVE ME BREDD")
return input("TYPE BREDD PRESS ENTER:")
def getUserIngredients():
howMany = int(input("how many ingredients?"))
outIngredients = []
for i in range(0, howMany):
print("GIVE ME STUFF")
ingredientName = input("TYPE STUFF PRESS ENTER:")
ingredient = getIngredientByName(ingredientName)
outIngredients.append(ingredient)
return outIngredients
wiches = []
bread = getUserBread()
yourWich = Sandwich(bread)
ingredients = getUserIngredients()
yourWich.addIngredients(ingredients)
wiches.append(yourWich)
for sammie in wiches:
print(sammie.getPrice())
sammie.printInstructions()