Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions python/src/basket_informations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,21 @@ class BasketInformations:
# The product of the basket
map = {}

def add_product_to_basket(self, product, price):
BasketInformations.map[product] = price
# The fact that the basket has promo code
code_de_promotion = False

def add_product_to_basket(self, product, price, is_promo_code):
if is_promo_code:
BasketInformations.code_de_promotion = True
else:
BasketInformations.map[product] = price

def get_basket_price(self, in_cents):
v = 0
for s in BasketInformations.map.values():
v += s
if BasketInformations.code_de_promotion:
v -= 100
return v * 100 if in_cents else Long(v)

def reset_basket(self):
Expand Down
2 changes: 1 addition & 1 deletion python/test/basket_informations_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ def test_a_basket_should_cost_0_when_empty(self):
self.assertEqual(self.basket.get_basket_price(False), 0)

def test_1000_otherwise(self):
self.basket.add_product_to_basket("product", 1000)
self.basket.add_product_to_basket("product", 1000, False)
self.assertEqual(self.basket.get_basket_price(False), 1000)