4. Robot Drama

A skit involving robots making decisions.

You are going to make a play in which robots interact.

Documentation:

Assignment in Brief

Assignment Elements

  • One robot interacts with another robot.
  • You create a new interface or abstract class for use.
  • Robots interact in a non-formulaic way.
  • Interesting plot line (please!). It’s supposed to be fun.

Assignment Timeline

  • Friday: Outline of the action which will happen. (Check in.)
  • Tuesday: You should have at least 3 classes/interfaces written. (Check in.)
  • Tuesday after Thanksgiving: project due.

SchoolBot abstract class

We decided that every robot in school will have four basic functions.

boolean isStudent();
boolean isTeacher();
boolean isHelpful();
Strategy getHelp();

Robots can be students or teachers. If a robot is helpful, then you can get a Strategy from it. (The idea is that the Strategy will get you help when you “doIt”.)

StudentBot looks for TeacherBot

To interact with other robots, I suggest using:

  • the enhanced Robot class
  • the neighbors() function

Robot vs UrRobot

Use the Robot class instead of UrRobot. This lets your robot detect some things in its environment. For example, nextToARobot() returns true if there is at least one other robot with the same coordinates. Links to the Robot documentation are at the top of this page.

neighbors

The myRobot.neighbors() function returns an Enumeration. An Enumeration is an object that is basically a list of items. There is a nextElement() function which gives you the next item in the list. (You start before the first item.) There is a hasMoreElements() which returns true if there is another element you can get.

Note: Karel the Robot is an old program and Enumeration is an old interface. New programs use an Iterator instead.

Last modified August 18, 2023: 2022-2023 End State (7352e87)