Assignment Programming
Assignment Programming
def browse_cars(self):
"""
Display a list of available cars.
"""
print("\nAvailable Cars:")
for car in self.cars:
if not car.sold:
print(f"Model: {car.model}, Year: {car.year}, Price: $
{car.price}")
print()
if choice == "1":
username = input("Enter username: ")
password = input("Enter password: ")
user = system.authenticate_user(username,
password)
if user:
if isinstance(user, Customer):
print(f"\nWelcome, Customer {user.username}!")
system.browse_cars()
elif isinstance(user, SalesRep):
print(f"\nWelcome, Sales Representative
{user.username}!")
while True:
print("\n1. View Available Cars\n2. Sell a Car\n3. View
Sales\n4. Logout")
rep_choice = input("Enter your choice: ")
if rep_choice == "1":
system.browse_cars()
elif rep_choice == "2":
customer_name = input("Enter customer name: ")
car_model = input("Enter car model to sell: ")
system.sell_car(user, customer_name, car_model)
elif rep_choice == "3":
system.show_sales(user)
elif rep_choice == "4":
break
else:
print("Invalid choice. Try again.")
else:
print("Invalid username or password. Try again.")
elif choice == "2":
system.browse_cars()
elif choice == "3":
print("Exiting the system. Goodbye!")
break
else:
print("Invalid choice. Try again.")
# Customers
# Username: customer01, Password: Custom@01,
Email: [email protected]
# Username: customer02, Password: Custom@02,
Email: [email protected]
# Sales Representatives
# Username: salesrep01, Password: Sales@01
# Username: salesrep02, Password: Sales@02
# Cars
# Model: Toyota, Year: 2021, Price: $50,000, Sold: No
# Model: BMW, Year: 2024, Price: $300,000, Sold: No
# Model: Ferrari, Year: 2018, Price: $80,000, Sold: No