Lab: Thursday June 30th
Let's go on a photo safari
A group of Photographers are going on a photo safari. Each photographer
has a camera and a recent snapshot to inspect.
The camera has a roll of film, with a certain number of photos
remaining and an indication whether the film is black & white or
color.
The snapshot has a description of the contents of the picture and the
height and width of the picture.
Create a data design using this information, representing Photographer,
Camera, and Snapshot. Transform this representation into Java.
A photographer is asked whether his snapshot is of a "lion". Develop a
program so that the Photographer can answer this question. (Hint: the
Photographer cannot directly inspect any properties of the Snapshot,
only the methods).
When the Photographer takes a
picture, she interacts with the Camera, which produces a Snapshot of a
set size (3x4) of a specified subject. The action of taking the picture
produces a new representation of the Photographer with this Snapshot.
Additionally, the photographer must advance the film in the Camera,
reducing by one the number of pictures available. The action of
advancing the film produces a new representation of the Camera, which
is used in creating a new representation of the Photographer.
Photographers like to have cameras specialized to their tastes.
Different cameras allow different size snapshots to be taken.
Some photographers use Disposable cameras, that can only produce 3x4
snapshots.
Some use SLR cameras that support different lenses. A 5x6 lens lets the
Photographer take 5x6 snapshots, a 10x30 lens 10x30 snapshots, and so
forth.
Some use Digital cameras that can produce 8x10 snapshots and have
inifinite film (so advancing the film does not change the
representation of the camera).
Update the camera design so that Disposable, SLR, and Digital will all
be kinds of Camera's (i.e. Camera will be the abstract parent of
Disposable, SLR, and Digital). Camera and all data that is a kind of
Camera should support the operations used by the Photographer.
Update Photographer and any test cases etc, as necessary.