Lab
3
Get started now
Building a fan ========================== 5 8.0x6.0x0.0625 sheets ========================== Duplicate part: 8.0x6.0x0.0625 sheet Copies: 5 Individual cost: $1.50 Individual weight: 0.3 lbs Total cost: $7.12 Total weight: 1.5 lbs ========================== 8.0x6.0x0.0625 sheet ========================== Length: 8.0 inches Width: 6.0 inches Thickness: 0.0625 inches Cost: $1.50 Weight: 0.3 lbsAn assembly consists of multiple different parts. Both the cost and weight of the assembly are determined by adding the cost and weight of each part in the assembly. However, the assembly has an additional construction cost which is $0.25 per sub-part in the assembly. The assembly maintains a `List` of all the parts that are stored in it. A duplicate part or an assembly may be a sub-part of another part. For example, in the cube option in the program [MachineDriver.java](MachineDriver.java), the cube consists of two parts: a set of metal sheets and several sets of nut-bolt pairs. The set of sheets is actually a duplicate part, consisting of six identical pieces of sheet metal. The sets of nut-bolt pairs are also a duplicate part, consisting of 36 identical nut-bolt pairs. Each nut-bolt pair is an assembly, consisting of both a nut and a bolt. This hierarchy of parts is illustrated in the diagram below. When a duplicate part or assembly prints the bill of materials, it first prints a summary of each part (including name, cost, and weight for each part), then prints the full bill of materials for each part. For example, the bill of materials for the cube in [MachineDriver.java](MachineDriver.java) is: ``` ========================== Cube ========================== Part: 36 Nut-Bolt Pairs Cost: $36.45 Weight: 0.247 lbs Part: 6 12.0x12.0x0.25 sheets Cost: $102.60 Weight: 21.6 lbs Total cost: $139.55 Total weight: 21.848 lbs ========================== 36 Nut-Bolt Pairs ========================== Duplicate part: Nut-Bolt Pair Copies: 36 Individual cost: $1.12 Individual weight: 0.007 lbs Total cost: $36.45 Total weight: 0.247 lbs ========================== Nut-Bolt Pair ========================== Part: 0.25x2.0 bolt Cost: $0.50 Weight: 0.006 lbs Part: 0.25 inch nut Cost: $0.12 Weight: 0.001 lbs Total cost: $1.12 Total weight: 0.007 lbs ========================== 0.25x2.0 bolt ========================== Diameter: 0.25 inches Length: 2.0 inches Cost: $0.50 Weight: 0.006 lbs ========================== 0.25 inch nut ========================== Diameter: 0.25 inches Cost: $0.12 Weight: 0.001 lbs ========================== 6 12.0x12.0x0.25 sheets ========================== Duplicate part: 12.0x12.0x0.25 sheet Copies: 6 Individual cost: $18.00 Individual weight: 3.6 lbs Total cost: $102.60 Total weight: 21.6 lbs ========================== 12.0x12.0x0.25 sheet ========================== Length: 12.0 inches Width: 12.0 inches Thickness: 0.25 inches Cost: $18.00 Weight: 3.6 lbs ``` As shown in the example above, format numeric values cleanly. In particular, dollar amounts should always include two places after the decimal. You may add new options to the example program, but do not edit the options provided in the example. Let the single `printBillOfMaterials()` call print everything. ## Appendix: Shovel option As a final example, the shovel option in the example program produces an assembly consisting of three different parts. ``` ========================== Shovel ========================== Part: 30.0x3.0x0.125 sheet Cost: $5.62 Weight: 1.125 lbs Part: 10.0x8.0x0.25 sheet Cost: $10.00 Weight: 2 lbs Part: 0.125x0.5 bolt Cost: $0.06 Weight: 0 lbs Total cost: $16.44 Total weight: 3.125 lbs ========================== 30.0x3.0x0.125 sheet ========================== Length: 30.0 inches Width: 3.0 inches Thickness: 0.125 inches Cost: $5.62 Weight: 1.125 lbs [... more sub-parts ...] ```