Предмет:
ИнформатикаАвтор:
pachecoclass Elevator:
count = 0
passenger_count = 0
def __init__(self, name):
self.name = name
Elevator.count += 1
def enter_elevator(self, number_of_passengers):
self.passenger_count += number_of_passengers
Elevator.passenger_count += number_of_passengers
def exit_elevator(self, number_of_passengers):
self.passenger_count -= number_of_passengers
Elevator.passenger_count -= number_of_passengers
@classmethod
def passenger_info(cls):
print("Total number of passengers in all elevators: {}".format(cls.passenger_count))
def elevator_info(self):
print("Number of passengers in elevator {}: {}".format(self.name, self.passenger_count))
elevator1 = Elevator("Elevator 1")
elevator2 = Elevator("Elevator 2")
elevator3 = Elevator("Elevator 3")
elevator1.enter_elevator(5)
elevator2.enter_elevator(10)
elevator3.enter_elevator(15)
Elevator.passenger_info()
elevator1.elevator_info()
elevator2.elevator_info()
elevator3.elevator_info()
elevator1.exit_elevator(3)
Elevator.passenger_info()
elevator1.elevator_info()
Автор:
hammerqvymДобавить свой ответ
Предмет:
Українська моваАвтор:
evangelineОтветов:
Смотреть