-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathboom_model.py
More file actions
78 lines (58 loc) · 1.66 KB
/
boom_model.py
File metadata and controls
78 lines (58 loc) · 1.66 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
# -*- coding: utf-8 -*-
"""
Created on Mon Jul 01 14:07:36 2013
@author: Tillsten
"""
#import traits
from __future__ import print_function
import decimal
class Item(object):
def __init__(self, name, price, image_path=None):
"""
A drink or something to eat
"""
self.name = name
self.price = decimal.Decimal(price)
self.image_path = image_path
class Register(object):
def __init__(self, cash):
self.cash = decimal.Decimal(cash)
Kasse = Register('0.00')
class Tab(object):
"""
Represents a client, has a tab.
"""
def __init__(self, name):
self.name = name
self.tab = []
def add_to_tab(self, prod):
self.tab.append(prod)
def remove_from_tab(self, prod):
self.tab.remove(prod)
def calc_total(self):
return self.calc_subtotal(self.tab)
def calc_subtotal(self, selected_prods):
total = decimal.Decimal('0.00')
for i in selected_prods:
total += i.price
return total
def make_recipe(self):
s = ''
for i in self.tab:
s += "{0:20} {1}\n".format(i.name, i.price)
s += '---------------------------\n'
s += "{0:20} {1}\n".format("TOTAL", self.calc_total())
return s
def pprint(self):
print(self.make_recipe())
if __name__ == '__main__':
ClubMate = Item('Club Mate', '1.50')
ClubMate.image_path = 'club_mate_flaschen.png'
Kickern = Item('Kickern', '3.00')
Till = Tab('Till')
Till.add_to_tab(ClubMate)
Till.add_to_tab(ClubMate)
Till.add_to_tab(ClubMate)
Till.add_to_tab(Kickern)
Till.pprint()
#print Till.alc_total()