Direction.java :  » Game » ka-50-attack » org » dvaletin » games » ka50 » Helicopter » Android Open Source

Android Open Source » Game » ka 50 attack 
ka 50 attack » org » dvaletin » games » ka50 » Helicopter » Direction.java
package org.dvaletin.games.ka50.Helicopter;

/**
 * @author Nicolas Gramlich
 * @since 02:29:05 - 08.07.2010
 */
public enum Direction {
  // ===========================================================
  // Elements
  // ===========================================================

  UP(), DOWN, LEFT, RIGHT;

  // ===========================================================
  // Constants
  // ===========================================================

  // ===========================================================
  // Fields
  // ===========================================================

  // ===========================================================
  // Constructors
  // ===========================================================

  // ===========================================================
  // Getter & Setter
  // ===========================================================

  // ===========================================================
  // Methods from SuperClass/Interfaces
  // ===========================================================

  // ===========================================================
  // Methods
  // ===========================================================

  public static int addToX(final Direction pDirection, final int pX) {
    switch(pDirection) {
      case UP:
      case DOWN:
        return pX;
      case LEFT:
        return pX - 1;
      case RIGHT:
        return pX + 1;
      default:
        throw new IllegalArgumentException();
    }
  }

  public static int addToY(final Direction pDirection, final int pY) {
    switch(pDirection) {
      case LEFT:
      case RIGHT:
        return pY;
      case UP:
        return pY - 1;
      case DOWN:
        return pY + 1;
      default:
        throw new IllegalArgumentException();
    }
  }

  public static Direction opposite(final Direction pDirection) {
    switch(pDirection) {
      case UP:
        return DOWN;
      case DOWN:
        return UP;
      case LEFT:
        return RIGHT;
      case RIGHT:
        return LEFT;
      default:
        return null;
    }
  }

  // ===========================================================
  // Inner and Anonymous Classes
  // ===========================================================
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.