forked from srinu2003/micro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcake.py
26 lines (24 loc) · 891 Bytes
/
cake.py
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
from menu import flavors,weights,decorations;
class Cake:
def __init__(this,weight,flavor,isCool,decoration,steps):
this.weight = weight
this.flavor = flavor
this.isCool = isCool
this.decoration = decoration
this.steps = steps
def printCake(this):
if this.isCool:
cool = "Yes"
else:
cool = "No"
if this.steps == 0:
this.steps = 'N/A'
else:
this.steps = str(this.steps)
print('| %s | %s | %s | %s | %s | %s |'%(this.flavor[0].center(15),str(this.weight).center(6),cool.center(5),this.decoration[0].center(12),this.steps.center(5),str(this.calculateCost()).center(5))
)
def calculateCost(this):
cost = this.flavor[1] * this.weight + this.decoration[1]
if this.isCool:
cost += cost + (cost * 0.2)
return cost