def main(): print("====> first cart") cart = ShoppingCart() cart.add_item() cart.remove_item() cart.add_item() cart.add_item() cart.add_item() cart.remove_item() cart.checkout() cart.pay() # Go shopping again print("====> second cart") cart = ShoppingCart() cart.add_item() cart.add_item() cart.checkout() cart.empty_cart() cart.add_item() cart.checkout() cart.pay() # Try to add another item print('====> Expect an error here.') cart.add_item()
def main(): shopping_cart = ShoppingCart() item_1 = Item("Banana", 2.5) item_2 = Item("Juice", 1.7) shopping_cart.add_item(item_1) shopping_cart.add_item(item_2) # shopping_cart.pay(PaypalPayment("*****@*****.**", "123456")) shopping_cart.pay( CreditCardPayment("Ivan Ivanov", "1234 1234 1234 1234", "10/21", "123"))
from product import Product from shopping_cart import ShoppingCart from payment_strategies import BlikStrategy, CreditCardStrategy if __name__ == '__main__': product1 = Product('Banana', 4.99) product2 = Product('Apple', 2.99) cart = ShoppingCart() cart.add_product(product1) cart.add_product(product2) cart.pay(BlikStrategy('*****@*****.**', '123456')) cart.pay( CreditCardStrategy('4111 1111 4555 1142', 'Jon Snow', '456', '09/27'))