Tomorin likes to collect stones, especially those with a unique shape. She has a collection box, with all the stones in sphere, cube, cuboid, and cylinder shapes inside. Now, she wants to find the stone with the largest and the smallest surface area in her collection, as well as the total surface area of all the stones in the collection. Can you help her?
Here are the formulas for the surface area of each shape:
We represent the stones as a hierarchy of classes. The base class is Stone
, which has a method getSurfaceArea()
that returns the surface area of the stone. The derived classes are SphereStone
, CubeStone
, CuboidStone
, and CylinderStone
, which calculate the surface area of their respective shapes on construction. Additionally, a CollectionBox
class is used to keep track of the largest and smallest surface areas of the stones in the collection.
You need to implement the following methods:
SphereStone
, CubeStone
, CuboidStone
, and CylinderStone
classes, which should take the parameters needed to calculate the surface area of the respective shapes and store the surface area in the surfaceArea
variable.CollectionBox
class, which should initialize the internal variables to keep track of the minimum, maximum, and total surface area of the stones in the collection.addStone()
method of the CollectionBox
class, which should take a Stone
object as a parameter and add it to the collection. This method should also update the minimum, maximum, and total surface area of the stones in the collection.4/3=1
in integer, and you should use 4.0/3.0
in double instead.This is a partial judge problem. You don’t need to implement the input function.
The input consists of multiple lines, each representing a stone in the collection. For each line, the first string is the type of stone, followed by the parameters needed to calculate the surface area. The types of stones are:
Sphere
: Sphere r pi
Cube
: Cube a
Cuboid
: Cuboid a b c
Cylinder
: Cylinder r h pi
This is a partial judge problem. You don’t need to implement the output function.
You should output the minimum surface area, maximum surface area, and the total surface area of all the stones in the collection. You should round the output to 2 decimal places. The output should be in the following format:
Minimum Surface Area: <min_surface_area>
Maximum Surface Area: <max_surface_area>
Total Surface Area: <total_surface_area>