Skip to content

Instantly share code, notes, and snippets.

@marceloemanoel
Created July 11, 2012 11:57
Show Gist options
  • Save marceloemanoel/3089927 to your computer and use it in GitHub Desktop.
Save marceloemanoel/3089927 to your computer and use it in GitHub Desktop.
Enum em java
public enum Direction {
NORTH {
public Direction turnLeft(){
return WEST;
}
public Direction turnRight(){
return EAST;
}
public Point move(Point currentPosition){
return new Point(currentPosition.getX(), currentPosition.getY() + 1);
}
},
SOUTH {
//a implementação para o sul
},
WEST {
// a implementação para o oeste
},
EAST {
// e a implementação para o leste
};
public abstract Direction turnLeft();
public abstract Direction turnRight();
public abstract Point move(Point currentPosition);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment