The buggles from Homework Assignment 2, becky, bobby, and bertie, had the foresight to copyright their Buggle Olympic Symbol. As a result, they made a killing on the use of the logo for Buggles Olympics memorabilia and merchandise. So, they decided to invest in a rug-making enterprise: The Buggle Bagel Ruggle Company, which designs and weaves rugs made by dropping bagels in interesting ways on a BuggleWorld grid.
Here is an example of a rug they created:
The buggles are great designers, but, unfortunately, they don't know much about manufacturing. It takes so long to hand-drop the bagels individually that it's impossible to make any money. Luckily for them, there is a way to automate the production of the rugs. As it turns out, the design shown above can be produced using just 4 different 3x3 grids of bagel patterns:
It is also helpful to realize that the rug design consists of three concentric rings of 3x3 grids, as indicated by the heavy black outines shown below (the lighter black lines demarcate the 3x3 grid patterns):
Download the hw5Buggles
folder from my download directory on panther. It should contain
BuggleWorld.java
,
Rug_BuggleWorld.java
,
and hw5Buggles.mcp
, among other things.
Just as we needed fred to be a new kind of Buggle, called a
LetterBuggle, in order to teach him to draw letters and course numbers,
this assignment uses a new kind of Buggle called a RugBuggle.
The RugBuggleWorld
class, an extension of
BuggleWorld
, contains a pre-written run()
method that creates a RugBuggle named "weaver" and sends it a
series of requests.
In the class RugBuggle
are headers for all the necessary methods.
Some of these methods have their bodies filled in, while others are
left blank for you to finish.
Rules:
bark
,
barkLoud
, and barkSoft
.
Be sure to follow the design recipe for writing the methods!
Also include a toString
method as in the FF examples.
Turn this in as a file named
AWDogs1.java
(with a main class named
AWDogs1
that tests everything).
toString
methods in all
non-abstract classes.
(Hint: For purposes of this
assignment, the different kinds of dogs differ only in what noise they
make, which is set when a new Dog object is created. Use the
super
keyword of Java, discussed on pp. 40-41 of FF, to
set the correct noise for each kind of Dog.)
Turn this in as a file named FFDogs1.java
,
with a main class named FFDogs1
that tests all your examples.
InteractiveIO
class
from the textbook, page 104, in a file named
InteractiveIO.java
. Note that this file has no main
method, since it's not intended as a stand-alone program.
AWDogs1.java
, calling it
AWDogs2.java
. Add read
, readi
,
and print
methods to this file as in exercise 1, p. 125.
Note that your print
method may be considerably
simpler than the examples in the book, because you've already
written toString
.
Also note that readi
depends on InteractiveIO
,
so add InteractiveIO.java
to the list of source files
in your project file (just as the buggles projects all include
BuggleWorld.java
).
FFDogs2.java
and adding
read
, readi
, and print
methods.
What goes wrong? Try to find a way to do this anyway.
Rug_BuggleWorld.java
with all the method bodies filled in, so that when the user clicks on
the "Run()" button, weaver will be created and draw a rug
exactly like the one above.
AWDogs1.java
, exactly as described in the AW book (except that you've
added toString
methods).
FFDogs1.java
.
AWDogs2.java
, which is simply AWDogs1.java
plus some I/O methods.
FFDogs2.java
, with as good a solution to the I/O methods as you
can come up with. Discuss (in a Java comment) what problems, if any,
you were unable to solve.