nachos.machine
Interface RiderInterface

All Superinterfaces:
Runnable
All Known Implementing Classes:
Rider

public interface RiderInterface
extends Runnable

A single rider. Each rider accesses the elevator bank through an instance of RiderControls.


Field Summary
static int dirDown
          Indicates an elevator intends to move down.
static int dirNeither
          Indicates an elevator intends not to move.
static int dirUp
          Indicates an elevator intends to move up.
 
Method Summary
 void initialize(RiderControls controls, int[] stops)
          Initialize this rider.
 void run()
          Cause the rider to use the provided controls to make the stops specified in the constructor.
 

Field Detail

dirDown

static final int dirDown
Indicates an elevator intends to move down.

See Also:
Constant Field Values

dirNeither

static final int dirNeither
Indicates an elevator intends not to move.

See Also:
Constant Field Values

dirUp

static final int dirUp
Indicates an elevator intends to move up.

See Also:
Constant Field Values
Method Detail

initialize

void initialize(RiderControls controls,
                int[] stops)
Initialize this rider. The rider will access the elevator bank through controls, and the rider will make stops at different floors as specified in stops. This method should return immediately after this rider is initialized, but not until the interrupt handler is set. The rider will start receiving events after this method returns, potentially before run() is called.

Parameters:
controls - the rider's interface to the elevator bank. The rider must not attempt to access the elevator bank in any other way.
stops - an array of stops the rider should make; see below.

run

void run()
Cause the rider to use the provided controls to make the stops specified in the constructor. The rider should stop at each of the floors in stops, an array of floor numbers. The rider should only make the specified stops.

For example, suppose the rider uses controls to determine that it is initially on floor 1, and suppose the stops array contains two elements: { 0, 2 }. Then the rider should get on an elevator, get off on floor 0, get on an elevator, and get off on floor 2, pushing buttons as necessary.

This method should not return, but instead should call controls.finish() when the rider is finished.

Specified by:
run in interface Runnable