In yesterday's Lab, you developed a VerticalPercolator
class that models the behavior of a solid material. Objects of this
class percolate straight down, but they do not percolate left or
right. The goal of today's Mini-Lab is to develop
a GravitationalPercolator
class. Objects of this class
will percolate down, left and right. This could be used as a model of a
fluid flowing down through down through a medium.
(As an alternative, you could choose to model a heavier, viscous fluid that
percolates down and to the lower left and lower right, but does not flow to
the left and right at the same level.)
As a first step, you will make a small change to
the VerticalPercolator
class that will make it easier to
adapt that code to this new problem. Currently,
the getPercolationLocation
method returns a single object
of type Location
. That design makes sense for
the VerticalPercolator
because an object of that class
can percolate to at most one location. However that approach won't
work for our GravitationalPercolator
.
Exercise 1 — Modifying VerticalPercolator:
|
Using the modified VerticalPercolator
class as a starting
point, it will be straightforward to implement the
GravitationalPercolator
.
Exercise 2 — Creating GravitationalPercolator:
|
At this point your VerticalPercolator
and GravitationalPercolator
classes are nearly
identical. One of the goals of the next Mini-Lab will be to factor out
the common code and move it into a common superclass.
The work you have done for this mini-lab will be part of the Percolation programming project, so you don't need to submit anything at this point.