This assignment will give you practice processing a binary file, manipulating binary data, using casts, and multiple inheritance. The assignment has two parts - processing a binary file and working with the 12-class multiple inheritance hierarchy shown below. You should only turn in one (set of) source code that contains both parts.
Geometric
Solid Type Code (first nibble value) |
Color
Code (second nibble value) |
1
= cylinder 2 = sphere 4 = rectangular prism 8 = cube |
0
= No color 1 = red 2 = blue 4 = green 8 = yellow |
1st Byte Toggled -Nibbles- -------- Doubles ---------- 147 0x12 0x1 0x2 3.41176 1.13333 4.36842 161 0x20 0x2 0 1.46154 201 0x48 0x4 0x8 5.60000 5.00000 9.60000 3.45455 1 0x80 0x8 0 7.54545 0 0x81 0x8 0x1 2.53846 1.80000 160 0x21 0x2 0x1 2.64706 3.83333 0 0x81 0x8 0x1 9.60000 8.16667 201 0x48 0x4 0x8 3.10000 1.76471 2.42857 2.50000 193 0x40 0x4 0 1.68421 3.40000 4.88889 ... |
Thing
Binary
data Representing Cylinder 2 doubles radius and height Sphere 1 double radius RectangularPrism 3 double length, width, and height Cube 1 double side ColoredCylinder 3 doubles radius, height, weight, color ColoredSphere 2 doubles radius, weight, color ColoredRectangularPrism 4 doubles length, width, height, weight, color ColoredCube 2 doubles side, weight, color |
Solid |
Volume |
Rectangular Solid |
V = l w h |
Sphere |
V = 4/3(pi)r3 |
Cylinder |
V = (pi)r2h
|
Cube |
V = s3 |
Do not
attempt to solve all of the program requirements in
one pass. There are
some sophisticated
requirements for this assignment.
Try to
“sneak up” on the solution. Check the instantiation
of the class objects before you attempt to use the overloaded insertion
operators.
You will need virtual inheritance as demonstracted in class.
Type
of
Object
Volume
Color
Density ColoredCylinder 41.4444 Blue 0.1054 Sphere 13.0773 ColoredRectangularPrism 268.8000 Yellow 0.0129 Cube 429.5920 ColoredCube 16.3573 Red 0.1100 ColoredSphere 77.6926 Red 0.0493 ColoredCube 884.7360 Red 0.0092 ColoredRectangularPrism 13.2857 Yellow 0.1882 RectangularPrism 27.9953 ... |