。它包括一个电梯模拟,接受用户输入的楼层数和使用电梯的人数。。
我意识到我的代码非常稀疏,有很多空白,但我真的不知道从这里走到哪里。
。任何其他的建议都会非常感谢和帮助。请注意,我不是在找人帮我做代码,而是握着我的手告诉我该走哪条路。在我看来,课程似乎完全让人迷惑不解。

import random

floors=raw_input('Please enter the number of floors for the simulation:')
while floors.isalpha() or floors.isspace() or int(floors) <=0:
    floors=raw_input('Please re enter a digit for number of floors:')
customers=raw_input('Please enter the number of customers in the building:')
while customers.isalpha() or customers.isspace() or int(customers) <0:
    customers=raw_input('Please re enter a digit for number of customers:')
count = 1

class building:
    def num_of_floors():
        num_of_floors = floors
    def customer_list():
        customer_list = customers
    def run(self):
    def output(self):
        print elevator.cur_floor

class elevator:
    def num_of_floors():
        building.num_of_floors
    def register_list():
        register_list = []
    def cur_floor(building):
        cur_floor = 1
    def direction(self):
        if elevator.cur_floor == 1:
            direction = up
        if elevator.cur_floor == floors:
            direction = down
    def move(self):
        if elevator.direction == up:
            cur_floor +=1
        if elevator.direction == down:
            cur_floor -=1
    def register_customer(self, customer):
        register_list.append(customer.ID)
    def cancel_customer (self, customer):
        register_list.remove(customer.ID)

class customer:
    def cur_floor(customer):
        cur_floor = random.randint(0,int(floors))
    def dst_floor(customer):
        dst_floor = random.randint(0,int(floors))
        while dst_floor == cur_floor:
            dst_floor = random.randint(0,int(floors))
    def ID():
        cust_id = count
        count+=1
    def cust_dict(cust_id,dst_floor):
        cust_dict = {cust_id:dst_floor}
    def in_elevator():
        in_elevator = 0
        if customer.ID in register_list:
            in_elevator = 1
    def finished():
        if customer.ID not in register_list:
            pass

最佳答案

你需要了解self
所有方法的参数。

构造器。
你需要理解__init__
对于你的成员变量。
你需要了解如何设置
self.varible功能。
You need to understand how to
main函数或
方法。
您需要了解如何从函数或方法中分配给return变量。

08-24 23:51