initial commit
This commit is contained in:
commit
3aca31de74
40 changed files with 1701 additions and 0 deletions
11
lift/.classpath
Normal file
11
lift/.classpath
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="/cs/labs.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
28
lift/.project
Normal file
28
lift/.project
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>2. Passenger lift</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
<filteredResources>
|
||||
<filter>
|
||||
<id>1678721711435</id>
|
||||
<name></name>
|
||||
<type>30</type>
|
||||
<matcher>
|
||||
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
||||
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
||||
</matcher>
|
||||
</filter>
|
||||
</filteredResources>
|
||||
</projectDescription>
|
2
lift/.settings/org.eclipse.core.resources.prefs
Normal file
2
lift/.settings/org.eclipse.core.resources.prefs
Normal file
|
@ -0,0 +1,2 @@
|
|||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
30
lift/src/OnePersonRidesLift.java
Normal file
30
lift/src/OnePersonRidesLift.java
Normal file
|
@ -0,0 +1,30 @@
|
|||
|
||||
import lift.LiftView;
|
||||
import lift.Passenger;
|
||||
|
||||
public class OnePersonRidesLift {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
final int NBR_FLOORS = 7, MAX_PASSENGERS = 4;
|
||||
|
||||
LiftView view = new LiftView(NBR_FLOORS, MAX_PASSENGERS);
|
||||
Passenger pass = view.createPassenger();
|
||||
int fromFloor = pass.getStartFloor();
|
||||
int toFloor = pass.getDestinationFloor();
|
||||
|
||||
pass.begin(); // walk in (from left)
|
||||
if (fromFloor != 0) {
|
||||
view.moveLift(0, fromFloor);
|
||||
}
|
||||
view.openDoors(fromFloor);
|
||||
pass.enterLift(); // step inside
|
||||
|
||||
view.closeDoors();
|
||||
view.moveLift(fromFloor, toFloor); // ride lift
|
||||
view.openDoors(toFloor);
|
||||
|
||||
pass.exitLift(); // leave lift
|
||||
pass.end(); // walk out (to the right)
|
||||
}
|
||||
}
|
21
lift/src/lift/Passenger.java
Normal file
21
lift/src/lift/Passenger.java
Normal file
|
@ -0,0 +1,21 @@
|
|||
package lift;
|
||||
|
||||
public interface Passenger {
|
||||
/** @return the floor the passenger starts at */
|
||||
int getStartFloor();
|
||||
|
||||
/** @return the floor the passenger is going to */
|
||||
int getDestinationFloor();
|
||||
|
||||
/** First, delay for 0..45 seconds. Then animate the passenger's walk, on the entry floor, to the lift. */
|
||||
void begin();
|
||||
|
||||
/** Animate the passenger's walk from the entry floor into the lift. */
|
||||
void enterLift();
|
||||
|
||||
/** Animate the passenger's walk out of the lift, to the exit floor. */
|
||||
void exitLift();
|
||||
|
||||
/** Animate the passenger's walk, on the exit floor, out of view. */
|
||||
void end();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue