Beispiel #1
0
  public void move() {

    if (face.equals(Direction.NORTH)) {
      point.move((int) point.getX(), (int) point.getY() + 1);
      // robot.getPoint().getY() < tableTop.getMaxY() - 1
    } else if (face.equals(Direction.EAST)) {
      point.move((int) point.getX() + 1, (int) point.getY());
      // robot.getPoint().getX() < tableTop.getMaxX() - 1
    } else if (face.equals(Direction.SOUTH)) {
      point.move((int) point.getX(), (int) point.getY() - 1);
      // robot.getPoint().getY() > 0
    } else if (face.equals(Direction.WEST)) {
      point.move((int) point.getX() - 1, (int) point.getY());
      // robot.getPoint().getX() > 0
    }
  }
Beispiel #2
0
  public void turnRight() {
    int bearing = this.face.getBearingValue();
    bearing++; // turn left

    if (bearing == 4) {
      bearing = 0;
    }

    setFace(Direction.getDirection(bearing));
  }
Beispiel #3
0
  public void turnLeft() {

    int bearing = this.face.getBearingValue();
    bearing--; // turn left

    if (bearing == -1) {
      bearing = 3;
    }

    setFace(Direction.getDirection(bearing));
  }