yangjason69

ThankYou

Nov 19th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.19 KB | None | 0 0
  1.  
  2. import kareltherobot.*;
  3. import java.awt.Color;
  4.  
  5. /**
  6.  * Write a concise summary of class ThankYou here.
  7.  *
  8.  * @author  Jason Yang
  9.  *
  10.  * @version 19 November 2016
  11.  */
  12. public class ThankYou extends Robot
  13. {
  14.     /**
  15.      * Creates a ThankYou object.
  16.      *
  17.      * @param street     specifies the vertical position on the grid
  18.      *                   of this robot.
  19.      * @param avenue     specifies the horizontal position on the grid
  20.      *                   of this robot.
  21.      * @param direction  specifies the direction of this robot.
  22.      * @param beepers    specifies this robot's number of beepers.
  23.      */
  24.     public ThankYou (int street, int avenue,
  25.     Direction direction, int beepers)
  26.     {
  27.         super(street, avenue, direction, beepers);
  28.     }
  29.  
  30.     /* ThankYou methods: */
  31.     /**
  32.      * Like the turnLeft method, the robot turns right.
  33.      */
  34.     public void turnRight(){
  35.         turnLeft();
  36.         turnLeft();
  37.         turnLeft();
  38.     }
  39.     /**
  40.      * The robot turns around 180 degrees.
  41.      */
  42.     public void turnAround(){
  43.         turnLeft();
  44.         turnLeft();
  45.     }
  46.     /**
  47.      * Puts a beeper down and moves one step forward.
  48.      */
  49.     public void putAndMove(){
  50.         putBeeper();
  51.         move();
  52.     }
  53.     /**
  54.      * Transitions from the upper right hand corner of one letter to the upper left hand corner of the next letter.
  55.      */
  56.     public void transitionUp(){
  57.         turnRight();
  58.         move();
  59.         move();
  60.     }
  61.     /**
  62.      * Transitions from the bottom right hand corner of one letter to the upper left hand corner of the next letter.
  63.      */
  64.     public void transitionDown(){
  65.         turnLeft();
  66.         move();
  67.         turnLeft();
  68.         move();
  69.         move();
  70.         turnRight();
  71.         move();
  72.     }
  73.     /**
  74.      * Transitions from the end of the first row of letters (the k in thanks) to the beginning of the second row of letters (the y in you)
  75.      */
  76.     public void transitionBig(){
  77.         turnLeft();
  78.         for (int i=0; i<12; i++)
  79.         {
  80.             move();
  81.         }
  82.         turnLeft();
  83.         for (int i=0; i<4; i++)
  84.         {
  85.             move();
  86.         }
  87.         turnLeft();
  88.     }
  89.     /**
  90.      * Puts down three beepers in a line.
  91.      */
  92.     public void three(){
  93.         putAndMove();
  94.         putAndMove();
  95.         putBeeper();
  96.     }
  97.     /**
  98.      * Puts down beepers in a "T" shape.
  99.      */
  100.     public void t(){
  101.         three();
  102.         turnAround();
  103.         move();
  104.         turnLeft();
  105.         pickBeeper();
  106.         three();
  107.         turnLeft();
  108.         move();
  109.         turnRight();
  110.     }
  111.     /**
  112.      * Puts down beepers in a "H" shape.
  113.      */
  114.     public void h(){
  115.         turnRight();
  116.         three();
  117.         turnAround();
  118.         move();
  119.         turnRight();
  120.         move();
  121.         putAndMove();
  122.         turnLeft();
  123.         move();
  124.         turnAround();
  125.         three();
  126.     }
  127.     /**
  128.      * Puts down beepers in a "A" shape.
  129.      */
  130.     public void a(){
  131.         turnRight();
  132.         move();
  133.         putAndMove();
  134.         putBeeper();
  135.         turnLeft();
  136.         move();
  137.         turnLeft();
  138.         move();
  139.         putAndMove();
  140.         putBeeper();
  141.         turnRight();
  142.         move();
  143.         turnRight();
  144.         move();
  145.         putAndMove();
  146.         putBeeper();
  147.     }
  148.     /**
  149.      * Puts down beepers in a "N" shape.
  150.      */
  151.     public void n(){
  152.         turnRight();
  153.         three();
  154.         turnLeft();
  155.         move();
  156.         turnLeft();
  157.         move();
  158.         putBeeper();
  159.         move();
  160.         turnRight();
  161.         move();
  162.         turnRight();
  163.         three();
  164.     }
  165.     /**
  166.      * Puts down beepers in a "K" shape.
  167.      */
  168.     public void k(){
  169.         turnRight();
  170.         three();
  171.         turnLeft();
  172.         move();
  173.         turnLeft();
  174.         putBeeper();
  175.         move();
  176.         move();
  177.         putBeeper();        
  178.     }
  179.     /**
  180.      * Puts down beepers in a "Y" shape.
  181.      */
  182.     public void y(){
  183.         putBeeper();
  184.         move();
  185.         turnRight();
  186.         move();
  187.         putAndMove();
  188.         putBeeper();
  189.         turnLeft();
  190.         move();
  191.         turnLeft();
  192.         move();
  193.         move();
  194.         putBeeper();
  195.     }
  196.     /**
  197.      * Puts down beepers in a "O" shape.
  198.      */
  199.     public void o(){
  200.         turnRight();
  201.         three();
  202.         turnLeft();
  203.         move();
  204.         turnLeft();
  205.         putBeeper();
  206.         move();
  207.         move();
  208.         putBeeper();
  209.         turnRight();
  210.         move();
  211.         turnRight();
  212.         three();
  213.     }
  214.     /**
  215.      * Puts down beepers in a "U" shape.
  216.      */
  217.     public void u(){
  218.         turnRight();
  219.         three();
  220.         turnLeft();
  221.         move();
  222.         putAndMove();
  223.         turnLeft();
  224.         three();
  225.     }
  226.     /**
  227.      * Draws out the words "THANK YOU".
  228.      */
  229.     public void run()
  230.     {
  231.         t();
  232.         transitionDown();
  233.         h();
  234.         transitionDown();
  235.         a();
  236.         transitionDown();
  237.         n();
  238.         transitionDown();
  239.         k();
  240.         transitionBig();
  241.         y();
  242.         transitionUp();
  243.         o();
  244.         transitionDown();
  245.         u();
  246.         move();
  247.     }
  248. }
Add Comment
Please, Sign In to add comment