Little Simulator In Java One

LittleSimulatorInJavaHistory


For a SpikeSolution we will need the following:

 Elevator1 can initialize to Floor1
 Person1 starts on Floor1
 Person1 requests elevator (pushes button)
 Elevator1 opens
 Person1 enters Elevator1 (exits Floor1)
 Elevator1 travels to Floor2
 Elevator1 opens
 Person1 exits Elevator1 (enters Floor2)

Is there anything else?


 // A developing implementation of LittleSimulator

public class Elevator { private int location;

public Elevator(){ location = 1; }

public int whatFloor(){ return(location); }

public void moveMe(){ if (location == 1) location = 2; else location = 1; } }

public class Person { private int location;

public Person(){ location = 1; }

public int whatFloor(){ return(location); }

public void getOnElevator(){ location = 0; }

public void getOffElevator( int elevatorLocationX ){ location = elevatorLocationX; } }

public class Spike { public static void main(String[] args){ Person person1 = new Person(); Elevator elevator1 = new Elevator(); person1.getOnElevator(); elevator1.moveMe(); person1.getOffElevator(elevator1.whatFloor()); } }


EditText of this page (last edited September 22, 1999) or FindPage with title or text search