📄 sphere.h
字号:
// ***************************************************// Header file Sphere.h for the class Sphere.// ***************************************************const double PI = 3.14159;class Sphere{public: Sphere(); // Default constructor: Creates a sphere and // initializes its radius to a default value. // Precondition: None. // Postcondition: A sphere of radius 1 exists. Sphere(double initialRadius); // Constructor: Creates a sphere and initializes // its radius. // Precondition: initialRadius is the desired // radius. // Postcondition: A sphere of radius initialRadius // exists. void setRadius(double newRadius); // Sets (alters) the radius of an existing sphere. // Precondition: newRadius is the desired radius. // Postcondition: The sphere誷 radius is newRadius. double getRadius() const; // Determines a sphere's radius. // Precondition: None. // Postcondition: Returns the radius. double getDiameter() const; // Determines a sphere's diameter. // Precondition: None. // Postcondition: Returns the diameter. double getCircumference() const; // Determines a sphere's circumference. // Precondition: PI is a named constant. // Postcondition: Returns the circumference. double getArea() const; // Determines a sphere's surface area. // Precondition: PI is a named constant. // Postcondition: Returns the surface area. double getVolume() const; // Determines a sphere's volume. // Precondition: PI is a named constant. // Postcondition: Returns the volume. void displayStatistics() const; // Displays statistics of a sphere. // Precondition: None. // Postcondition: Displays the radius, diameter, // circumference, area, and volume.private: double theRadius; // the sphere誷 radius}; // end class// End of header file.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -