Skip to content

Commit 360ed81

Browse files
committed
goods and sales
1 parent 4adfa5c commit 360ed81

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

newcodes/answers/q64.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env python
2+
# coding=utf-8
3+
4+
class Goods:
5+
def __init__(self, price,whole_sale, discount):
6+
self.price = price
7+
self.whole_sale = whole_sale
8+
self.discount = discount
9+
10+
def register_sale(self, count):
11+
self.count = count
12+
if self.count > self.whole_sale:
13+
self.price = self.price * self.discount
14+
15+
def display_sale(self):
16+
print("The count of goods is:{0}".format(self.count))
17+
sales = self.price * self.count
18+
print("The total sales is:{0}".format(round(sales, 2)))
19+
20+
if __name__ == "__main__":
21+
price = 106.78
22+
whole_sale = 60
23+
discount = 0.7
24+
goods = Goods(price, whole_sale, discount)
25+
goods.register_sale(100)
26+
goods.display_sale()
27+

0 commit comments

Comments
 (0)