Lab 5 - Bucket Volume
Due: Thursday, February 28, 2008
This assignment asks you to model a cylindrical Bucket of water.
Inside of this bucket may be at most one item that is either spherical
cubical. Your model of this bucket should be Comparable and also
throw an exception if the user attempts to place an item into the bucket
which is too large to fit.
Specifics of the Bucket class
- The class should be called Bucket
- The constructor should accept the radius and height of
the cylindrical bucket
- The getBucketRadius(...) method should return the bucket's
- The getBucketLength(...) method should return the bucket's
- The placeItem(...) method should accept the edgeLength
of the cube
- The removeItem(...) method should take the item out of the bucket,
leaving it empty
- The getItemDimension(...) method should return the length of the
item's edge, or throw the EmptyBucketException, of your
own creation, if empty
- The getItemVolume(...) method should return the total volume
of the item, or throw the EmptyBucketException, of your
own creation, if empty
- The getBucketVolume(...) method should return the total volume
of the bucket
- The getAvailableBucketVolume(...) method should return the total
available volume of the bucket, subtracting away the volume of the
item, if any
- The toString() method should properly serialize the properties of
both the bucket and any possible item
- The equals() method should compare buckets based only upon their
- The Bucket class should be Comparable, based only
upon the availabel volume
- All dimensions should be doubles.
- Vcylinder=PI * radius2*height
- The widest point on a square is from one corner to the opposing
corner. Think c2=a2+b2
The Test Driver main()
The main() method of the Bucket class should serve as a non-interactive
test driver. We will be grading this based upon its thoroughness -- and
the ease with which a reader can interprete the output. Please make the
output easy to understand, without knowledge of the code.
The InteractiveBucket main()
Please create an additional class, InteractiveBucket that creates
two buckets and compares them -- except that, unlike the main() of the
Bucket class, this main() should be interactive -- it should
prompt the user for all values. This method need not be an exhaustive test.
It need only alow the user to create two buckets, with or without
items inside -- at the user's option -- and then compare them.
It should do something user-friendly in the event that an item will not
fit into the bucket. In other words, it should handle the exception.