Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Lesson3;
- import kareltherobot.UrRobot;
- import kareltherobot.World;
- import java.awt.*;
- import java.beans.BeanProperty;
- import java.sql.Wrapper;
- import java.util.Scanner;
- public class Activity1 extends UrRobot {
- public Activity1(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);
- Activity1 zgod = new Activity1(1,1,North,-1);
- zgod.shuttleRun();
- }
- /**
- * Function for having the robot go up or down in a set
- * @return void
- * */
- public void upDown(){
- move();
- move();
- move();
- turnLeft();
- turnLeft();
- }
- /**
- * Function for having the robot turn right
- * @return void
- * */
- public void turnRight(){
- turnLeft();
- turnLeft();
- turnLeft();
- }
- /**
- * Function for doing the reps in a set
- * @param reps counts the number of reps
- * @return void
- * */
- public void rep(int reps){
- for (int i = 0; i < reps; i++) { // loop to make the robot go up and down one time for each rep
- upDown();
- putBeeper();
- upDown();
- }
- }
- /**
- * Function for executing the shuttle run
- * @return void
- * */
- public void shuttleRun(){
- Scanner scanner = new Scanner(System.in); // Create a Scanner object
- System.out.println("How many sets do you want ZGOD to do?");
- int sets = scanner.nextInt(); //creates int to save the number of sets
- if (sets > 10){
- World.setSize(10,sets); // sets the number of avenues to however many sets the user wants the robot to do if the number is greater than 10
- }
- System.out.println("How many reps do you want ZGOD to do for each set?");
- int reps = scanner.nextInt(); // int for storing the number of reps that the user wants the robot to do
- for (int i = 0; i < sets; i++) { // loop that runs the reps as many times as there are sets
- rep(reps);
- turnRight();
- move();
- turnLeft();
- }
- }
- }
Add Comment
Please, Sign In to add comment