Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- Carlos Garcia
- L3 A2
- Stairs
- */
- package Lesson3;
- import kareltherobot.UrRobot;
- import kareltherobot.World;
- import java.awt.*;
- import java.util.Scanner;
- public class Activity2 extends UrRobot {
- public Activity2(int street , int avenue , Direction direction , int beeperCount){
- super(street, avenue, direction, beeperCount, Color.PINK);
- }
- public static void main(String[] args) {
- World.setDelay(50);
- World.setVisible();
- World.setBeeperColor(Color.blue);
- World.setSize(10,10);
- World.showSpeedControl(true);
- World.readWorld("Lesson3World2.kwld");
- Activity2 zgod = new Activity2(1,1,North,-1);
- zgod.goUp();
- }
- /**
- * Function to turn right
- * @return void
- * */
- public void turnRight(){
- turnLeft();
- turnLeft();
- turnLeft();
- }
- /**
- * Function to go up a single step
- * @return void
- * */
- public void upStair(){
- move();
- turnRight();
- move();
- turnLeft();
- }
- /**
- * Function to go up the whole staircase
- * @return void
- * */
- public void goUp() {
- for (int i = 0; i < 7 ; i++) { // loop to run the upStair function and pick a beeper 7 times
- upStair();
- pickBeeper();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement