Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 15th, 2012  |  syntax: None  |  size: 0.76 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Extend and enumeration constant
  2. private enum Mode{
  3.   FRIGHTENED, BLINKING extends FRIGHTENED, SCATTER
  4. }
  5.        
  6. switch (some_mode){
  7.   case FRIGHTENED:
  8.     // This would trigger when the actual "some_mode" is set
  9.     //  to FRIGHTENED or BLINKING
  10.     break;
  11.   case BLINKING:
  12.     // This would only trigger if the actual "some_mode" is set to BLINKING
  13. }
  14.        
  15. if (some_mode == Mode.FRIGHTENED){
  16.   // The behavior in FRIGHTENED and BLINKING mode is the same. The only
  17.   //  difference is the way they are visualized.
  18. }
  19.        
  20. switch (some_mode){
  21.   case BLINKING:
  22.     // This would only trigger if the actual "some_mode" is set to BLINKING
  23.     // no break statement!
  24.   case FRIGHTENED:
  25.     // This would trigger when the actual "some_mode" is set
  26.     //  to FRIGHTENED or BLINKING
  27. }