public Position cellToDot(Stripe stripe, Position p) { Integer x = null; Integer y = null; switch (stripe) { case UP: y = p.y(); x = p.x() + 1; break; case RIGHT: break; case DOWN: break; case LEFT: x = p.x(); y = p.y() + 1; break; default: break; } return new Position(x, y); }
public Movement dotToMovement(Position a, Position b) { Stripe stripe = null; Integer x = null; Integer y = null; x = Math.min(a.x(), b.x()); y = Math.min(a.y(), b.y()); if (a.x() == b.x()) { stripe = Stripe.LEFT; } else if (a.y() == b.y()) { stripe = Stripe.UP; } if (a.x() == this.GAME_SIZE && b.y() != this.GAME_SIZE) { x = this.GAME_SIZE - 1; stripe = Stripe.RIGHT; } if (a.y() == this.GAME_SIZE && b.x() != this.GAME_SIZE) { y = this.GAME_SIZE - 1; stripe = Stripe.DOWN; } Position position = new Position(x, y); return new Movement(position, stripe); }