Gerard-Meier

Java Enum Constructor.

Jun 5th, 2011
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.86 KB | None | 0 0
  1. import java.awt.Color;
  2.  
  3. /**
  4.  *
  5.  * @author Gerjo Meier
  6.  * Enum demo.
  7.  *
  8.  */
  9.  
  10. public enum TileState {
  11.     ERROR (Color.cyan,          '@'),
  12.     TESTING (Color.pink,        'T'), // walkable
  13.     WALKABLE (Color.magenta,    ' '), // walkable
  14.     NONWALKABLE (Color.black,   '#'),
  15.     START (Color.green,         'S'),
  16.     END (Color.red,             'E'),
  17.     PATH (Color.blue,           '+');
  18.  
  19.     private final Color backgroundColor;
  20.     private final char asciiRepresentation;
  21.    
  22.     TileState(Color backgroundColor, char asciiRepresentation) {
  23.         this.backgroundColor     = backgroundColor;
  24.         this.asciiRepresentation = asciiRepresentation;
  25.     }
  26.  
  27.     public final Color getBackgroundColor() {
  28.         return backgroundColor;
  29.     }
  30.    
  31.     public final char getAsciiRepresentation() {
  32.         return asciiRepresentation;
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment