SHARE
TWEET

Untitled

a guest Nov 15th, 2019 93 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package Lesson3;
  2. import kareltherobot.*;
  3.  
  4. public class Lesson3Activity1 extends UrRobot{
  5.  
  6.     //constructor from UrRobot for my alphabot
  7.     public Lesson3Activity1(int x, int y, Direction d, int b) {
  8.         super(x, y, d, b);
  9.     }
  10.  
  11.     public static void main(String[] args) {
  12.         World.readWorld("Lesson3World1.kwld");
  13.  
  14.         World.setDelay(15);
  15.         World.setVisible();
  16.  
  17.         Lesson3Activity1 alphaBot = new Lesson3Activity1(4,3,North, 0);
  18.  
  19.         //runs the program
  20.         alphaBot.shuttleRun();
  21.  
  22.     }
  23.  
  24.     /**
  25.      * compiles all of the other functions to do the entire shuttle run
  26.      * @param
  27.      * @return void
  28.      */
  29.     public void shuttleRun() {
  30.         for(int i = 0; i < 3; i++){
  31.             //so that the robot doesn't instantly move to the right one row
  32.             if(i > 0){
  33.                 moveRight();
  34.             }
  35.             shuttleGrab();
  36.         }
  37.     }
  38.  
  39.     /**
  40.      *  allows the robot to "turn right" in the source code
  41.      *  rather than turn left 3 times
  42.      * @param
  43.      * @return void
  44.      */
  45.     public void moveRight() {
  46.         turnLeft();
  47.         turnLeft();
  48.         turnLeft();
  49.         move();
  50.         turnLeft();
  51.     }
  52.  
  53.     /**
  54.      * a single shuttle run, from the beeper and back
  55.      * @param
  56.      * @return void
  57.      */
  58.     public void shuttleGrab() {
  59.         //runs 5 times to pick up all the beepers in a row
  60.         for(int i = 0; i < 5; i++) {
  61.             run();
  62.             pickBeeper();
  63.             turnLeft();
  64.             turnLeft();
  65.             run();
  66.             turnLeft();
  67.             turnLeft();
  68.             putBeeper();
  69.         }
  70.     }
  71.  
  72.     /**
  73.      * makes the run to the beeper a single line
  74.      * @return void
  75.      */
  76.     public void run() {
  77.         for(int i = 0; i < 3; i++ ){
  78.             move();
  79.         }
  80.     }
  81.  
  82. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top