# | Problem | Pass Rate (passed user / total user) |
---|---|---|
13038 | Geometry |
|
13039 | Comet Observatory with No Money |
|
Description
Implement six existed classes Plane, Solid, Triangle, Rectangle, Tetrahedron, Cuboid.
Plane:
Protected Variables:
- base(int) as the length of plane’s base.
- height(int) as the length of plane’s height.
note that 0 <= base, height <= 100.
Protected Methods:
- double calculateArea() - Return plane’s area(base * height).
Solid: (derived from Plane)
Protected Variables:
- base(derived from Plane) as the length of bottom shape’s base.
- height(derived from Plane) as the length of bottom shape’s height.
- height(int) as the length of solid’s height.
note that 0 <= height <= 100.
Protected Methods:
- double calculateVolume() - Return solid’s volume(base area * height).
Triangle: (derived from Plane)
Protected Variables:
- base(derived from Plane) as the length of triangle’s base.
- height(derived from Plane) as the length of triangle’s height.
Constructors:
- The parameterized constructor Triangle(int b, int h) should initialize triangle’s base, height to b, h.
Public Methods:
- void set(int i) – Should set both triangle’s base and height to i.
- void set(int b, int h) – Should set both triangle’s base and height to b, h.
- void info() – Should print triangle’s information as below format.
[Triangle] Base: base, Height: height, Area: area(scaled to 2nd decimal point)
For example: [Triangle] Base: 20, Height: 30, Area: 300.00
Protected Methods:
- double calculateArea() - Return rectangle's area(base area / 2).
Rectangle: (derived from Plane)
Protected Variables:
- base(derived from Plane) as the length of rectangle’s base.
- height(derived from Plane) as the length of rectangle’s height.
Constructors:
- The parameterized constructor Rectangle(int b, int h) should initialize rectangle's base, height to b, h.
Public Methods:
- void set(int i) – Should set both rectangle's base and height to i.
- void set(int b, int h) – Should set both rectangle's base and height to b, h.
- void info() – Should print rectangle’s information as below format.
[Rectangle] Base: base, Height: height, Area: area(scaled to 2nd decimal point)
For example: [Rectangle] Base: 20, Height: 30, Area: 600.00
Protected Methods:
- double calculateArea() - Return rectangle's area(base area).
Tetrahedron(三角體): (derived from Solid)
Protected Variables:
- base(derived from Plane) as the base of tetrahedron’s bottom.
- height(derived from Plane) as the height of tetrahedron’s bottom.
- height(derived from Solid) as the height of tetrahedron.
Constructors:
- The parameterized constructor Tetrahedron(int b, int h, int k) should initialize tetrahedron’s bottom base to b, tetrahedron’s bottom height to h, tetrahedron’s height to k.
Public Methods:
- void set(int i) – Should set all tetrahedron’s bottom base, tetrahedron’s bottom height, and tetrahedron’s height to i.
- void set(int b, int h, int k) – Should set tetrahedron’s bottom base to b, tetrahedron’s bottom height to h, and tetrahedron’s height to k..
- void info() – Should print tetrahedron’s information as below format.
[Tetrahedron] Plane-base: base, Plane-height: height(derived from Plane), Height: height(derived from Plane), Volume: volume(scaled to 2nd decimal point)
For example: [Tetrahedron] Plane-base: 20, Plane-height: 30, Height: 40, Volume: 6000.00
Protected Methods:
- double calculateVolume() - Return tetrahedron’s volume( 1/6 * base solid volume )
Cuboid(長方體): (derived from Solid)
Protected Variables:
- base(derived from Plane) as the base of cuboid‘s bottom.
- height(derived from Plane) as the height of cuboid’s bottom.
- height(derived from Solid) as the height of cuboid.
Constructors:
- The parameterized constructor Cuboid(int b, int h, int k) should initialize cuboid’s bottom base to b, tetr cuboid’s ahedron’s bottom height to h, cuboid’s height to k.
Public Methods:
- void set(int i) – Should set all cuboid’s bottom base, cuboid’s bottom height, and cuboid’s height to i.
- void set(int b, int h, int k) – Should set cuboid’s bottom base to b, cuboid’s bottom height to h, and cuboid’s height to k..
- void info() – Should print cuboid’s information as below format.
[Cuboid] Plane-base: base, Plane-height: height(derived from Plane), Height: height(derived from Plane), Volume: volume(scaled to 2nd decimal point)
For example: [Cuboid] Plane-base: 20, Plane-height: 30, Height: 40, Volume: 24000.00
Protected Methods:
- double calculateVolume() - Return cuboid’s volume(base solid volume)
Hints of function.cpp is commented in function.h. Download and check it out.
Input
No need to handle input. (Input would be number 1~5 to represent the index of test-case)
Output
Depend on test case show in main.cpp.
Sample Input Download
Sample Output Download
Partial Judge Code
13038.cppPartial Judge Header
13038.hTags
Discuss
Description
You are an astronomer(天文學家) at a very poor comet observatory(彗星觀測站). The observatory is too poor to even own a telescope(望遠鏡), but your boss still asks you to find a few comets a week. How could this happen???
Fortunately, you are also a very technical programmer. And you found a way to intercept(攔截) satellite packets(衛星封包) that other observatories found comets. You decided to change a little packet information, and submit them to your boss.
Input
Packets always contain three parts of information, the comet’s name, the observation time, and the comet’s velocity, and are separated by SPACE. For example: 1P/Halley 2020-11-23T08:17:46+8 100
Details of the information:
[1P/Halley]
- Comet’s name: 1P/Halley.
- Comet’s type: P. Usually use the capital English letter before slash (/) to represent the type of a comet.
[2020-11-23T08:17:46+8]
- The format is: yyyy-mm-ddThh:mm:ssZ.
- Use capital ‘T’ to separate date information and time information.
- Z represents the time zone, when the time zone is GMT+8 than Z = +8; usually use capital ‘Z’ to represent the GMT+0.
[100]
- The velocity of the comet. The unit is miles per second.
note that 1 mile = 1.609344 kilometer.
Output
Output should follow as below format:
packet:"packet_information", length:length_of_ packet_information
[type] comet_type
[name] comet_name
[time] observation_time
[velocity] comet_velocitykm/s
Note that you should change the format of time information to different format as: yyyymmddThhmmssZ. For example, the packet’s time information may be like: 1996-02-05T17:25:09-11, and you should change them to: 19960205T172509-11
Also, the unit of velocity should change to kilometers per second, and scaled to 2nd decimal points.