User Tools

Site Tools


robot_olympics

Robot Olympics

Karel is practicing for the Robot Olympics. One of karel's events is the shuttle race. The shuttle race requires karel to move around two beepers in a figure 8 pattern. Write a program that instructs karel to walk a figure 8 pattern with as few instructions as possible. Karel must stop in the same place as it starts and must be facing the same direction.

import java.awt.Color;
import kareltherobot.*;
public class Olympics implements Directions 
{
    public static void main(String[] args)
    {
    	World.setDelay(30);
    	World.setSize(6, 4);
    	World.setBeeperColor(Color.CYAN);
    	World.placeBeepers(4, 2, 1);
    	World.placeBeepers(2, 2, 1);  	
    	World.setVisible();
    	task();
    }
    public static void task()
    {
    	Robot karel = new Robot(1,2,North,0);
      // Your code here
    	karel.turnOff();
    }
}

API (Application Programming Interface)

robot_olympics.txt · Last modified: 2019/08/18 12:41 by frchris

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki