harvester
The Harvester could also be called a Roomba– this robot will pick up all the beepers, ending facing West at Street7, Avenue 2.
If you have a strategy, go for it, and try it out. If you want a suggestion you can try this:
- A method could pick up a row beepers, stoping when there are no others
- A method that would turn North and turn toward the new row
- If there are beepers to pick up, continue again, otherwise
turnOff()
Harvester.java
import kareltherobot.Robot; // @author Your Name public class Harvester extends Robot { public Harvester(int street, int avenue, Direction direction, int beepers) { super(street, avenue, direction, beepers); } public void nameYourMethodHere() { // your code here } }
HarvesterRunner.java
import kareltherobot.*; public class HarvesterRunner implements Directions { public static void main(String[] args) { String field = "streets 8\n" + "avenues 10\n" + "beepers 3 4 1\n" + "beepers 3 3 1\n" + "beepers 6 7 1\n" + "beepers 6 6 1\n" + "beepers 6 5 1\n" + "beepers 6 4 1\n" + "beepers 6 3 1\n" + "beepers 2 7 1\n" + "beepers 2 6 1\n" + "beepers 2 5 1\n" + "beepers 2 4 1\n" + "beepers 2 3 1\n" + "beepers 5 7 1\n" + "beepers 5 6 1\n" + "beepers 5 5 1\n" + "beepers 5 4 1\n" + "beepers 5 3 1\n" + "beepers 4 7 1\n" + "beepers 4 6 1\n" + "beepers 4 5 1\n" + "beepers 4 4 1\n" + "beepers 4 3 1\n" + "beepers 7 7 1\n" + "beepers 7 6 1\n" + "beepers 7 5 1\n" + "beepers 7 4 1\n" + "beepers 7 3 1\n" + "beepers 3 7 1\n" + "beepers 3 6 1\n" + "beepers 3 5 1"; World.getWorld(field); World.setVisible(); task(); } private static void task() { Harvester farmer = new Harvester(2,2,East,0); // your code here to use your new method(s) farmer.turnOff(); } }
harvester.txt · Last modified: 2020/08/27 11:44 by frchris