CS111 Lab 2 Agenda, morning sections

PreLab

Finding Abstractions

Scenario
Today in lab you are going to help Buggles ben and barb figure out how to draw a checkerboard. They've brainstormed a lot of possible ways to draw out a checkerboard in BuggleWorld. Your job is to figure out which idea of theirs is best.

For each idea, create a new class of Buggle that will be able to draw the checkerboard in that particular manner. Each class of Buggle should have the makeCheckerBoard method defined. You should try to implement the class using the least amount of code possible. "Code" is counted as the number of method calls in your extended Buggle class. As you create that many of the "super-Buggles" above, you may notice that many of them do some of the same things. That's because they're really all extensions of the CheckerBuggle. When it is useful to do so, you should put commonly used methods into a separate CheckerBuggle class and make the other Buggles extend this new class.

Restrictions: Every Buggle starts at (1,1). You can not use setPosition() or setHeading(). The checkerboard will be black and red. The first square (1,1) is black.

Hints: Try to look for patterns that repeat. Start with small patterns and build up in complexity. Patterns that are used repeatedly are good bets for abstracting into your own custom made methods.

Special Note: To make it easier to see your work, there is a special method our Buggles will understand. It's contract is
public void rest ()
Buggle rests for an eighth of a second.

We will demonstrate how this method can help you in lab. You can not use this method in your homework or anywhere else. Normal Buggles don't understand how to take a break!

Checker Board Strategies

1) RowBuggle
RowBuggle creates checkerboards by moving back and forth across the board horizontally. RowBuggle first moves to the right.

(On your own -- optional) SquareBuggle
SquareBuggle creates checkerboards by finishing 2 x 2 pieces of the checkerboard one at a time.

2) LBuggle
LBuggle creates checkerboards by finishing L-shaped pieces one at a time.
L   square

3) SpiralBuggle
SpiralBuggle creates checkerboards by moving in a counter-clockwise spiral around the checkerboard from the outside in.

4) MazeBuggle
MazeBuggle creates checkerboards by moving in concentric squares starting at (1,1) and working outwards. MazeBuggle first moves to the right.


gratuitous checker board

You can find the files to work with in the /usr/users/cs111/download directory on nike.wellesley.edu. Download the entire CS111Lab2 folder.