User Tools

Site Tools


robot_olympics

This is an old revision of the document!


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();
    }
}

robot_olympics.1566138780.txt.gz · Last modified: 2019/08/18 10:33 by frchris

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki