class Product: def __init__(self, name, price): self.name = name self.price = price class ShoppingCart: def __init__(self): self.items = [] def add_item(self, product): self.items.append(product) def calculate_total(self): return sum(item.price for item in self.items) class EShop: def __init__(self): self.products = [Product("Product 1", 10), Product("Product 2", 20), Product("Product 3", 30)] self.shopping_cart = ShoppingCart() def display_products(self): print("Available Products:") for idx, product in enumerate(self.products, start=1): print(f"{idx}. {product.name} - ${product.price}") def add_to_cart(self, product_idx): product = self.products[product_idx - 1] self.shopping_cart.add_item(product) print(f"{product.name} added to cart.") def checkout(self): total = self.shopping_cart.calculate_total() print(f"Total: ${total}") print("Thank you for shopping with us!") def main(): eshop = EShop() while True: print("\n1. Display Products") print("2. Add to Cart") print("3. Checkout") print("4. Exit") choice = input("Enter your choice: ") if choice == '1': eshop.display_products() elif choice == '2': eshop.display_products() product_idx = int(input("Enter the product number to add to cart: ")) eshop.add_to_cart(product_idx) elif choice == '3': eshop.checkout() break elif choice == '4': print("Exiting...") break else: print("Invalid choice. Please try again.") if __name__ == "__main__": main()