diff --git a/python/src/basket_informations.py b/python/src/basket_informations.py index bbcaebf..5d9f94a 100644 --- a/python/src/basket_informations.py +++ b/python/src/basket_informations.py @@ -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): diff --git a/python/test/basket_informations_test.py b/python/test/basket_informations_test.py index a823a84..e577cb2 100644 --- a/python/test/basket_informations_test.py +++ b/python/test/basket_informations_test.py @@ -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) \ No newline at end of file