데블스캠프2011/다섯째날/HowToWriteCodeWell/권순의,김호동 (rev. 1.1)
Source ¶
public class Elevator {
private int max;
private int min;
private int floor;
private boolean inElevator;
private boolean button;
public Elevator(int i, int j) {
max = i;
min = j;
floor = 1;
inElevator = false;
button = false;
}
public int floor() {
return floor;
}
public void goTo(int i) {
if(i <= max && i >= min && inElevator ){
floor = i;
} else if (i < min){
floor = min;
} else if (i > max){
floor = max;
}
}
public void press() {
button = true;
}
public void in() {
if(button) {
inElevator = true;
button = false;
}
}
public void out() {
inElevator = false;
}
}