- One double data field named length with default values 1.0 to denote all sides of the cube.
- A no-arg constructor that creates a default cube.
- A constructor that creates a cube with the specified length.
- The accessor methods for all three data fields.
- A method named getArea() that returns the area/volume of this cube.
- A method named getPerimeter() that returns the perimeter of this cube.
- A method named toString() that returns a string description for the cube.
- The toString() method is implemented as follows:
return "cube: length = " + length;
Draw the UML diagram that involves the classes Cube and GeometricObject. Implement the class. Write a test program that creates a Cube object with side 5, sets color yellow and filled true, and displays the area, perimeter, color, and whether filled or not.
No comments:
Post a Comment