Project 2 CarBuying
Project 2 CarBuying
1. Car: This class will represent a car with its attributes (price, fuel
efficiency, brand, etc.).
2. CarShop: This class will represent the car shop that contains
available cars.
1
import pandas as pd
class Car:
self.model = model
self.price = price
self.fuel_efficiency = fuel_efficiency
self.brand = brand
self.horsepower = horsepower
self.safety_rating = safety_rating
self.color = color
def __repr__(self):
class CarShop:
def __init__(self):
self.cars = []
self.cars.append(car)
def get_available_cars(self):
return self.cars
2
class CarBuyer:
self.budget = budget
self.min_fuel_efficiency = min_fuel_efficiency
self.brand_preference = brand_preference
self.min_safety_rating = min_safety_rating
matching_cars = [
return matching_cars
available_cars = car_shop.get_available_cars()
filtered_cars = self.filter_cars(available_cars)
if not filtered_cars:
else:
3
print(car)
# Example usage:
car_shop = CarShop()
try:
buyer.recommend_car(car_shop)
4
except ValueError: