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).

  • 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 the doPlanting() method. 2. Implement the Forester interface in OakPlanter, MaplePlanter and BushPlanter. 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 and DropMover.
      • 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 the march() and crawl() methods.
      • march(): go three steps
      • crawl(): go one step and drop a beeper
    • Create a DrillSargent class that bosses two ArmyCaricature robots. The drill sargent should have a void bootCamp(ArmyCaricature a, ArmyCaricature b) method that tells a to do three marches and b to do three crawls.
    • Verify that your DrillSargent works by giving it a SpeedyMover and a DropMover.

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

     abstract public String[] getColumnNames();
Last modified August 18, 2023: 2022-2023 End State (7352e87)