Karel 4.1-4.4
Very important chapter: Choreographer, Contractor, Strategy, Spy, Observer. Design patterns in Java.
-
Monday, October 23, 2017: Read Section 4.1-4.3 and do Exercise 3.5 (DiamondBot) with a Choreographer robot.
-
Tuesday October 24, 2017: Section 4.2 review (abstract class, override methods).
- Class: make a robot (team) to create my figure 4.2b ending from the old blog. Then make a robot (team) to pick up my figure 4.2b start.
- Homework: Read Section 4.4.
- What is the function of an interface?
- What does delegation mean in cs?
-
Wednesday, October 25, 2017: Section 4.4 (interfaces)
- Class: review box on page 76 (purpose of interface, no methods in an interface)
- Class: review box on page 79 (references can point anywhere)
- Class: “delegation”.
- Assignment:
Forester
. The Forester plants trees and bushes. In the robot world, you see a top view of the forest - tall plants are represented by lots of beepers, short plants are represented by few beepers in a pile. Oak trees are tall (7 beepers in a location). Maple trees are medium height (3 beepers), and bushes are only 1 beeper tall but they take up four locations instead of one. 1. Make a Forester interface that has thedoPlanting()
method. 2. Implement the Forester interface inOakPlanter
,MaplePlanter
andBushPlanter
. 3. Demonstrate with a short program that plants two oak trees 5 squares apart, and a maple next to a bush.
-
Thursday, October 26, 2017: Practice for quiz Friday.
- Create two robot classes:
SpeedyMover
andDropMover
.- SpeedyMover moves two steps when told to move one.
- DropMover drops a beeper and moves when told to move.
- Create an interface
ArmyCaricature
that defines themarch()
andcrawl()
methods.march()
: go three stepscrawl()
: go one step and drop a beeper
- Create a
DrillSargent
class that bosses twoArmyCaricature
robots. The drill sargent should have avoid bootCamp(ArmyCaricature a, ArmyCaricature b)
method that tellsa
to do three marches andb
to do three crawls. - Verify that your
DrillSargent
works by giving it aSpeedyMover
and aDropMover
.
- Create two robot classes:
Quiz 4.1-4.4 on Friday
You should be able to demonstrate the following skills from Sections 4.1-4.4.
- Create a new class (including constructor from memory).
- Instance variables to remember helper robots.
- Abstract class, then concrete implementation to fill in missing parts.
- Interface: create and implement.
- Comparison of abstract class and interface.
Additional Notes
-
Read: old notes, still good.
-
Android programming has an AbstractCursor class that handles many commom behaviors. Notice that some of the methods are not there, like:
abstract public String[] getColumnNames();