Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import kareltherobot.*;
- public abstract class SuperKarel extends Robot implements Directions
- {
- public SuperKarel (int street, int avenue, Direction direction, int beepers)
- { super(street, avenue, direction, beepers);
- }
- public void turnRight()
- {
- turnLeft();
- turnLeft();
- turnLeft();
- }
- public void turnAround()
- {
- turnLeft();
- turnLeft();
- }
- public boolean rightIsClear()
- {
- turnRight();
- if (frontIsClear()) {
- turnLeft();
- return true;
- }
- turnLeft();
- return false;
- }
- public boolean leftIsClear()
- {
- turnLeft();
- if (frontIsClear()) {
- turnRight();
- return true;
- }
- turnRight();
- return false;
- }
- public void faceNorth()
- {
- if (facingEast())
- {
- turnLeft();
- }
- if (facingSouth())
- {
- turnLeft();
- turnLeft();
- }
- if (facingWest())
- {
- turnLeft();
- turnLeft();
- turnLeft();
- }
- }
- public void faceSouth()
- {
- if (facingWest())
- {
- turnLeft();
- }
- if (facingNorth())
- {
- turnLeft();
- turnLeft();
- }
- if (facingEast())
- {
- turnLeft();
- turnLeft();
- turnLeft();
- }
- }
- public void faceEast()
- {
- if (facingSouth())
- {
- turnLeft();
- }
- if (facingWest())
- {
- turnLeft();
- turnLeft();
- }
- if (facingNorth())
- {
- turnLeft();
- turnLeft();
- turnLeft();
- }
- }
- public void faceWest()
- {
- if (facingNorth())
- {
- turnLeft();
- }
- if (facingEast())
- {
- turnLeft();
- turnLeft();
- }
- if (facingSouth())
- {
- turnLeft();
- turnLeft();
- turnLeft();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement