Created
July 11, 2012 11:57
-
-
Save marceloemanoel/3089927 to your computer and use it in GitHub Desktop.
Enum em java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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