In this week's lab you will learn about
Designing an Algorithm
Inheritance
Creating services
Flow of Control (if statements and while loops)
Background
CaveBot (a child or subclass of the RobotSE class - check the API for the new services this class provides) likes to explore caves and find buried treasure with his metal detector. CaveBot will enter a cave and find the buried treasure and collecting all of it and then returning back to his car to put it all the treasure in its car.
Program Specification
Develop a java Program called Explorer.java, this class will have the special main method in it where you will create a City (note: we have provided cave .txt files that will set up the caves for you, so you do not have to worry about creating the Walls or Things. Take a look at the API for the City class). Design a subclass of RobotSE in a file named CaveBot.java. This is where you will provide services to help the CaveBot accomplish its task. It is your task to design a general algorithm for solving the general problem. Specifically, you are to design (create at least) Two methods that help the CaveBot accomplish its goals. The first task the CaveBot has is to enter a cave and gather all the Things from the cave (maybe call it explore( ). Once the CaveBot reaches the end of the cave, it needs to turn around and head back to his car (what would be a good name for this service?). The cave can be of any length and the number of things can be of any amount (this should start you thinking: does there have to be a single thing at every intersection - no Can there be 0 or 50 things at any intersection - yes at any given intersection there may be nothing or there be any int number of Things. In addition, each cave is different, so you can't hard-code code your algorithm for just one cave instead, (Hint) look for ways to determine when you reach the end of the cave and when you have picked up all the things below the robot. I suggest taking a look at the API for Robot and RobotSE.
Before you do anything, develop an algorithm in pseudocode to solve the problem at hand. This is to be done by placing comments directly in the main method of the Explorer.java file, like I have done in class. For example
//Create a City
//Create a CaveBot at the appropriate intersection - see figures below
//etc...
Implement your algorithm, remember to use step-wise refinement, and test as you go. Do not try to write the whole program before you test it!
After your CaveBot has successfully cleared cave1.txt, test your CaveBot with cave2.txt, and finally cave3.txt (note: these files are available for you to download, just make sure that you download them to the same folder where your code is; ask your TA if you have trouble with this).
Sample of Cave 1:
Initial situation:

Final situation:
Files needed for this lab:
CaveBot.java
Explorer.java
As always, the source code must be indented properly and contain comments that describe your algorithm. The use of proper indentation is considered good programming style, and you are expected to use good programming style.