Ejemplo n.º 1
0
 @Override
 public boolean equals(Object obj) {
   Pos target = (Pos) obj;
   if (this.getX() == target.getX() && this.getY() == target.getY()) {
     return true;
   } else {
     return false;
   }
 }
Ejemplo n.º 2
0
 /**
  * 移動可能か判断
  *
  * @param toDirection 進行方向
  * @return 移動可能ならTrue
  */
 public boolean canMove(Pos toDirection) {
   boolean retFlg = true;
   int moveX = this.getX() + toDirection.getX();
   int moveY = this.getY() + toDirection.getY();
   if (moveX < Common.X_MIN_LEN
       || moveX >= Common.X_MAX_LEN
       || moveY < Common.Y_MIN_LEN
       || moveY >= Common.Y_MAX_LEN) {
     retFlg = false;
   }
   return retFlg;
 }
Ejemplo n.º 3
0
 /**
  * 指定した方向に移動する
  *
  * @param toDirection 進行方向
  */
 public void doMove(Pos toDirection) {
   setX(getX() + toDirection.getX());
   setY(getY() + toDirection.getY());
 }