class Car:
def __init__(self, name, fuel, time):
self.name = name
self.fuel = fuel
self.time = time
class ParkingLot:
def __init__(self):
self.electric_zone = ["B-1", "B-2"]
self.compact_zone = ["C-1", "C-2"]
self.general_zone = ["G-1", "G-2"]
def park_car(self, car):
if car.fuel == "전기차" and self.electric_zone:
spot = self.electric_zone.pop(0)
fee = car.time * 1000 * 0.5
print(f"전기차 구역 {spot} 배정. 총 요금 {int(fee)}원(할인 적용)")
elif car.fuel == "경차" and self.compact_zone:
spot = self.compact_zone.pop(0)
fee = car.time * 1000
print(f"경차 구역 {spot} 배정. 총 요금 {int(fee)}원")
elif self.general_zone:
spot = self.general_zone.pop(0)
fee = car.time * 1000
print(f"일반 구역 {spot} 배정. 총 요금 {int(fee)}원")
else:
print("빈자리 없음. 주차 불가.")
my_car = Car("테슬라", "전기차", 125)
parking_lot = ParkingLot()
parking_lot.park_car(my_car)
To embed this project on your website, copy the following code and paste it into your website's HTML: