pair programming设计(伪)--by Junyuan Xie & Yuanwei Lu

这次的pair programming任务是设计一个电梯调度程序,因为已经提供了测试框架,所以这个设计其实只是练手,不会真正使用。

 

Pair Project: 电梯调度问题API设计

by 谢俊源 & 陆元伟

在我们的设计中,总共有3个大类:Elevator, Passenger, Scheduler,以及一个小类:Clock;

下面是我们的具体设计:

Passenger:

PassengerWeight ;

SourceFloor;

DestFloor;

ArriveTime;

PassengerName;

SendRequest();  //send request (up or down) to the scheduler

OpenGate();  //ask scheduler to tell elevator to stop

CloseGate();  // ask scheduler to tell elevator to close the door

 

Elevator:

WeightCarring;

MaximumWeight;

CurrentFloor;

CurrentDirection(Up or Down);

RunOrStop;

ElevatorSpeed;

FloorToStop;

OverWeightWarning();

StateUpdate();

StateSender(); //send the state of the elevator to scheduler

 

Scheduler:

Elevator1State(weight, floor, direction, OverWeight or not);

Elevator2State;

Elevator3State;

Elevator4State;

ComingPassengerState(weight, destination, current floor);

ElevatorCall();    //send orders to elevators

ElevatorUpdate(); //update the states of the 4 elevators

PassengerStateUpdate();

Initialization(); //default state settings of the elevators

 

上面的设计中,Passenger所有的指令都是传送给Scheduler的,通过Scheduler来调度Elevator响应Passenger的指令,同时Elevator也只与Scheduler进行互动,把自己的信息传送给Scheduler。

 

你可能感兴趣的:(programming)