AP Computer Science A
This lab explores a central idea in Object Oriented Programming. You will look at extending classes to build specific functionality. You will created methods and look at:
Implement your solution to the harvester problem. Once you have a working solution, open the solution package and see an alternative method of solution.
Karel sometimes works as a pin-setter in a bowling alley. Write a program that instructs karel to transform the initial situation (a beeperless world) into the final situation (shown below).
The figure below represents a baseball field of beepers. Write a program that places the beepers in a diamond shape. Hint: You should be able to use some of the code you created for problem #1.
Create a program that spells HELLO as shown below. (Hint: More than one robot may be needed). Note, you will need to create the classes from scratch. Use the structure given in problems 1 and 2.
Write a program where the numbers, 3, 2 and 1 are displayed in beepers. These should look like a countdown (i.e. the 3 appears, is removed, the 2 appears, is removed, the 1 appears and then is removed).
Take your time setting up your classes and think about our Harvester vs. Planter classes from before.
**These numbers should disappear before the next number is written**
Suppose we define a method in a robot class like this.
public void move()
{
super.move();
move();
}
What will happen if we send our robot such a method? If you want to test this, start your robot facing West or South. What is the meaning of the move instruction within this method?