10/19/2010

BCS2234 20/10/ 2010 Lab Activities on Inheritance

Design a class named Cube that extends GeometricObject. The class contains:

  • 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.
area of cube =length*length*length

  • A method named getPerimeter() that returns the perimeter of this cube.
perimeter of cube = 12 * length
  • 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:

Cara download Installer windows 10 dalam format ISO

1. Jika anda bercadang untuk download windows 10 melalui website rasmi windows - pilihan untuk download dalam format ISO tidak di berikan.  ...