Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import kareltherobot.*;
- import java.awt.Color;
- /**
- * Write a concise summary of class ThankYou here.
- *
- * @author Jason Yang
- *
- * @version 19 November 2016
- */
- public class ThankYou extends Robot
- {
- /**
- * Creates a ThankYou object.
- *
- * @param street specifies the vertical position on the grid
- * of this robot.
- * @param avenue specifies the horizontal position on the grid
- * of this robot.
- * @param direction specifies the direction of this robot.
- * @param beepers specifies this robot's number of beepers.
- */
- public ThankYou (int street, int avenue,
- Direction direction, int beepers)
- {
- super(street, avenue, direction, beepers);
- }
- /* ThankYou methods: */
- /**
- * Like the turnLeft method, the robot turns right.
- */
- public void turnRight(){
- turnLeft();
- turnLeft();
- turnLeft();
- }
- /**
- * The robot turns around 180 degrees.
- */
- public void turnAround(){
- turnLeft();
- turnLeft();
- }
- /**
- * Puts a beeper down and moves one step forward.
- */
- public void putAndMove(){
- putBeeper();
- move();
- }
- /**
- * Transitions from the upper right hand corner of one letter to the upper left hand corner of the next letter.
- */
- public void transitionUp(){
- turnRight();
- move();
- move();
- }
- /**
- * Transitions from the bottom right hand corner of one letter to the upper left hand corner of the next letter.
- */
- public void transitionDown(){
- turnLeft();
- move();
- turnLeft();
- move();
- move();
- turnRight();
- move();
- }
- /**
- * 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)
- */
- public void transitionBig(){
- turnLeft();
- for (int i=0; i<12; i++)
- {
- move();
- }
- turnLeft();
- for (int i=0; i<4; i++)
- {
- move();
- }
- turnLeft();
- }
- /**
- * Puts down three beepers in a line.
- */
- public void three(){
- putAndMove();
- putAndMove();
- putBeeper();
- }
- /**
- * Puts down beepers in a "T" shape.
- */
- public void t(){
- three();
- turnAround();
- move();
- turnLeft();
- pickBeeper();
- three();
- turnLeft();
- move();
- turnRight();
- }
- /**
- * Puts down beepers in a "H" shape.
- */
- public void h(){
- turnRight();
- three();
- turnAround();
- move();
- turnRight();
- move();
- putAndMove();
- turnLeft();
- move();
- turnAround();
- three();
- }
- /**
- * Puts down beepers in a "A" shape.
- */
- public void a(){
- turnRight();
- move();
- putAndMove();
- putBeeper();
- turnLeft();
- move();
- turnLeft();
- move();
- putAndMove();
- putBeeper();
- turnRight();
- move();
- turnRight();
- move();
- putAndMove();
- putBeeper();
- }
- /**
- * Puts down beepers in a "N" shape.
- */
- public void n(){
- turnRight();
- three();
- turnLeft();
- move();
- turnLeft();
- move();
- putBeeper();
- move();
- turnRight();
- move();
- turnRight();
- three();
- }
- /**
- * Puts down beepers in a "K" shape.
- */
- public void k(){
- turnRight();
- three();
- turnLeft();
- move();
- turnLeft();
- putBeeper();
- move();
- move();
- putBeeper();
- }
- /**
- * Puts down beepers in a "Y" shape.
- */
- public void y(){
- putBeeper();
- move();
- turnRight();
- move();
- putAndMove();
- putBeeper();
- turnLeft();
- move();
- turnLeft();
- move();
- move();
- putBeeper();
- }
- /**
- * Puts down beepers in a "O" shape.
- */
- public void o(){
- turnRight();
- three();
- turnLeft();
- move();
- turnLeft();
- putBeeper();
- move();
- move();
- putBeeper();
- turnRight();
- move();
- turnRight();
- three();
- }
- /**
- * Puts down beepers in a "U" shape.
- */
- public void u(){
- turnRight();
- three();
- turnLeft();
- move();
- putAndMove();
- turnLeft();
- three();
- }
- /**
- * Draws out the words "THANK YOU".
- */
- public void run()
- {
- t();
- transitionDown();
- h();
- transitionDown();
- a();
- transitionDown();
- n();
- transitionDown();
- k();
- transitionBig();
- y();
- transitionUp();
- o();
- transitionDown();
- u();
- move();
- }
- }
Add Comment
Please, Sign In to add comment