Advertisement
yangjason69

FourOne

Jan 28th, 2017
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.27 KB | None | 0 0
  1. import kareltherobot.*;
  2. import java.awt.Color;
  3.  
  4. /**
  5.  * Write a concise summary of class FourOne here.
  6.  *
  7.  * @author  Jason Yang
  8.  * @version 1/28/2017
  9.  */
  10. public class FourOne extends Utility
  11. {
  12.     /**
  13.      * Creates a FourOne object.
  14.      *
  15.      * @param street     specifies the vertical position on the grid
  16.      *                   of this robot.
  17.      * @param avenue     specifies the horizontal position on the grid
  18.      *                   of this robot.
  19.      * @param direction  specifies the direction of this robot.
  20.      * @param beepers    specifies this robot's number of beepers.
  21.      */
  22.     public FourOne (int street, int avenue,
  23.            Direction direction, int beepers)
  24.     {
  25.         super(street, avenue, direction, beepers);
  26.     }
  27.     /* FourOne methods: */
  28.     public void vertical()
  29.     {
  30.         putAndMove();
  31.         putAndMove();
  32.         putAndMove();
  33.         putAndMove();
  34.         putBeeper();
  35.     }
  36.    
  37.     public void horizontal()
  38.     {
  39.         moveAndPut();
  40.         moveAndPut();
  41.     }
  42.    
  43.     public void transitionHOne()
  44.     {
  45.         turnAround();
  46.         move();
  47.         move();
  48.         turnRight();
  49.     }
  50.    
  51.     public void transitionHTwo()
  52.     {
  53.         move();
  54.         turnLeft();
  55.         move();
  56.         move();
  57.         turnAround();
  58.     }
  59.    
  60.     public void h()
  61.     {
  62.         vertical();
  63.         transitionHOne();
  64.         horizontal();
  65.         transitionHTwo();
  66.         vertical();
  67.     }
  68.    
  69.     public void horizontalBack()
  70.     {
  71.         turnAround();
  72.         move();
  73.         move();
  74.     }
  75.    
  76.     public void transitionE()
  77.     {
  78.         turnRight();
  79.         move();
  80.         move();
  81.         turnRight();
  82.     }
  83.    
  84.     public void e()
  85.     {
  86.         vertical();
  87.         turnLeft();
  88.         horizontal();
  89.         horizontalBack();
  90.         transitionE();
  91.         horizontal();
  92.         horizontalBack();
  93.         transitionE();
  94.         horizontal();
  95.     }
  96.    
  97.     public void l()
  98.     {
  99.         vertical();
  100.         turnLeft();
  101.         horizontal();
  102.     }
  103.    
  104.     public void o()
  105.     {
  106.         vertical();
  107.         turnLeft();
  108.         horizontal();
  109.         move();
  110.         turnLeft();
  111.         vertical();
  112.         turnLeft();
  113.         horizontal();
  114.         move();
  115.     }
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement