U E D R , A S I H C RSS

데블스캠프2011/다섯째날/HowToWriteCodeWell/권순의,김호동 (rev. 1.1)

데블스캠프2011/다섯째날/How To Write Code Well/권순의,김호동

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;		
	}
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:29:12
Processing time 0.0128 sec