import random class Lift(object): def _init_(self,floors,passengers_in,direction ="up",cur_floor=1): self.total_floors = floors self.reg_list = [] self.floor = cur_floor self.direct = direction def move(self): if self.total_floors == self.floors: self.direct = "down" if self.direct == "up" : self.floor += 1 else : self.floor -= 1 def get_in(self,passenger): self.reg_list.append(passenger) def get_out(self,passenger): self.reg_list.remove(passenger) class Building(object): def _init_(self,floors,passengers,lift): self.total_floors=floors self.passengers=passengers def run(self): while lift.floor != 0: for passenger in self.passengers: print(passenger) if lift.floor == passenger.on_floor: lift.reg_list.append(passenger) passenger.indicator = 1 elif lift.floor == passenger.going_floor: lift.reg_list.remove(passenger) passenger.indicator = 0 passenger.fin = 1 lift.move() def output(self): pass class Passenger(object): def _init_(self,ID,floors,cur_floor=0,end_floor=0,in_lift=0, finished=0): self.ident = ID self.indicator = in_lift self.fin = finished cur_floor = random.randint(1, floors) self.on_floor = cur_floor end_floor = random.randint (1, floors) while end_floor == cur_floor: end_floor = random.randint(1, floors) self.going_floor = end_floor passenger_count = int(input("How many passengers are in the building?: ")) floor_count = int(input("How many floors does the building have?: ")) pass_list=[] for i in range(1,passenger_count+1): pass_list.append(Passenger(i,floor_count)) elevator = Elevator(floor_count,cus_list) building = Building(floor_count,cus_list, elevator)
elevator simulator...whats the wrong at this code?
Messages In This Thread |
elevator simulator...whats the wrong at this code? - by tasos710 - Jun-04-2019, 08:36 PM
RE: elevator simulator...whats the wrong at this code? - by Yoriz - Jun-04-2019, 08:52 PM
RE: elevator simulator...whats the wrong at this code? - by ichabod801 - Jun-05-2019, 12:38 AM
RE: elevator simulator...whats the wrong at this code? - by metulburr - Jun-05-2019, 11:05 PM
RE: elevator simulator...whats the wrong at this code? - by micseydel - Jun-11-2019, 01:38 AM
elevator simulator...can anyone add output commands at this code? - by tasos710 - Jun-05-2019, 04:08 PM
|
Users browsing this thread: 1 Guest(s)