a***@gmail.com
2014-11-07 15:43:43 UTC
public class NestIFElevator {
public boolean openDoor = false;
public int currentFloor = 1;
public Final int TOP_FLOOR = 10;
public Final int MIN_FLOOR = 1;
public void doorOpen(){
System.out.println("Opening Door");
openDoor = true;
System.out.println("Door is Open");
}
public void closeDoor(){
System.out.println("Closing Door");
openDoor = false;
System.out.println("Door is Close");
}
public void goUp(){
System.out.println("Going up 1 floor");
currentFloor++;
System.out.println("Floor:" +currentFloor);
if(currentFloor == TOP_FLOOR){
System.out.println("Cannot go up");
}
else{
openDoor = true;
System.out.println("Door is Open");
}
public void goDown(){
if(currentFloor == MIN_FLOOR){
System.out.println("Cannot go down");
}
if(currentFloor > MIN_FLOOR){
if(!openDoor){
System.out.println("Going Down 1 Floor.");
currentFloor--;
System.out.println("Floor:"+currentFloor);
}
}
}
}
public boolean openDoor = false;
public int currentFloor = 1;
public Final int TOP_FLOOR = 10;
public Final int MIN_FLOOR = 1;
public void doorOpen(){
System.out.println("Opening Door");
openDoor = true;
System.out.println("Door is Open");
}
public void closeDoor(){
System.out.println("Closing Door");
openDoor = false;
System.out.println("Door is Close");
}
public void goUp(){
System.out.println("Going up 1 floor");
currentFloor++;
System.out.println("Floor:" +currentFloor);
if(currentFloor == TOP_FLOOR){
System.out.println("Cannot go up");
}
else{
openDoor = true;
System.out.println("Door is Open");
}
public void goDown(){
if(currentFloor == MIN_FLOOR){
System.out.println("Cannot go down");
}
if(currentFloor > MIN_FLOOR){
if(!openDoor){
System.out.println("Going Down 1 Floor.");
currentFloor--;
System.out.println("Floor:"+currentFloor);
}
}
}
}