Mini Project Info
Mini Project Info
fun and educational endeavor. Here's a basic outline to get you started:
User Interface: You can create a simple text-based interface using Python's input()
function to prompt users for their choices. For a more advanced project, you can
explore GUI frameworks like Tkinter or web frameworks like Flask or Django.
Product Catalog: Define a list or dictionary of shoe products with attributes such
as name, brand, size, price, and availability.
Shopping Cart: Implement a shopping cart where users can add and remove items
before finalizing their purchase.
Payment System: For a more advanced project, you can integrate a payment system
using APIs
This code now includes a simulate_payment() function that prompts the user to
choose a payment method (Credit Card, PayPal, or Cash on Delivery) and then
displays a message indicating successful payment. This is just a simulation; in a
real-world application, you would integrate with payment APIs for actual
transactions.
class Shoe:
def __init__(self, name, brand, size, price, available):
self.name = name
self.brand = brand
self.size = size
self.price = price
self.available = available
class ShoppingCart:
def __init__(self):
self.items = []
def total_price(self):
return sum(item.price for item in self.items)
def display_catalog(products):
print("Available Shoes:")
for idx, product in enumerate(products, 1):
print(f"{idx}. {product.name} - {product.brand} - Size: {product.size} - $
{product.price}")
def main():
# Sample shoe products
products = [
Shoe("Sneakers", "Nike", 9, 100, True),
Shoe("Boots", "Timberland", 10, 150, True),
Shoe("Loafers", "Gucci", 8, 200, False),
]
cart = ShoppingCart()
while True:
display_catalog(products)
print()
choice = input("Enter the number of the shoe you want to add to cart (or
'checkout' to complete purchase): ")
if choice.lower() == 'checkout':
print(f"Total price: ${cart.total_price()}")
break
try:
choice = int(choice)
if 1 <= choice <= len(products):
chosen_product = products[choice - 1]
if chosen_product.available:
cart.add_item(chosen_product)
print(f"{chosen_product.name} added to cart.")
print()
else:
print("Sorry, this item is currently unavailable.")
print()
else:
print("Invalid choice. Please enter a valid number.")
print()
except ValueError:
print("Invalid input. Please enter a number or 'checkout'.")
if __name__ == "__main__":
main()