Biblioteca Java - Rev 32
Subversion Repositories:
(root)/Courses and labs samples/ISP/Exemple_ISP_Cluj_2015/ElevatorCurs/src/elevatorcurs/model/Elevator.java @ 34
package elevatorcurs.model;
import java.util.Observable;
/**
*
* @author Mihai Hulea mihai.hulea@aut.utcluj.ro
*/
public class Elevator extends Observable{
private int position;
private Direction currentDir;
public Elevator() {
currentDir = Direction.HOLD;
}
public void move(){
switch(currentDir){
case UP:{
position = position + 1;
setChanged();
notifyObservers(this);
break;
}
case DOWN:{
position = position - 1;
setChanged();
notifyObservers(this);
break;
}
case HOLD: {}
}
}
public void setCurrentDir(Direction dir){
this.currentDir = dir;
}
public Direction getCurrentDir(){
return currentDir;
}
public int getPosition(){
return position;
}
public String toString(){
return "Elevator: pos="+position+": dir="+currentDir;
}
}