Advertisement
GARC923

L3A2 Carlos Garcia

Oct 20th, 2022
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.38 KB | None | 0 0
  1. /**
  2. Carlos Garcia
  3. L3 A2
  4. Stairs
  5. */
  6.  
  7. package Lesson3;
  8.  
  9. import kareltherobot.UrRobot;
  10. import kareltherobot.World;
  11.  
  12. import java.awt.*;
  13. import java.util.Scanner;
  14.  
  15.  
  16. public class Activity2 extends UrRobot {
  17.     public Activity2(int street , int avenue , Direction direction , int beeperCount){
  18.         super(street, avenue, direction, beeperCount, Color.PINK);
  19.     }
  20.  
  21.  
  22.  
  23.     public static void main(String[] args) {
  24.         World.setDelay(50);
  25.         World.setVisible();
  26.         World.setBeeperColor(Color.blue);
  27.         World.setSize(10,10);
  28.         World.showSpeedControl(true);
  29.         World.readWorld("Lesson3World2.kwld");
  30.  
  31.         Activity2 zgod = new Activity2(1,1,North,-1);
  32.  
  33.         zgod.goUp();
  34.  
  35.     }
  36.    
  37.     /**
  38.      * Function to turn right
  39.      * @return void
  40.      * */
  41.     public void turnRight(){
  42.         turnLeft();
  43.         turnLeft();
  44.         turnLeft();
  45.     }
  46.    
  47.     /**
  48.      * Function to go up a single step
  49.      * @return void
  50.      * */
  51.     public void upStair(){
  52.         move();
  53.         turnRight();
  54.         move();
  55.         turnLeft();
  56.     }
  57.  
  58.     /**
  59.      * Function to go up the whole staircase
  60.      * @return void
  61.      * */
  62.     public void goUp() {
  63.         for (int i = 0; i < 7 ; i++) { // loop to run the upStair function and pick a beeper 7 times
  64.             upStair();
  65.             pickBeeper();
  66.         }
  67.     }
  68.  
  69.  
  70. }
  71.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement