1. Create a base class named Point consisting of x and y data members representing point coordinates. From this class, derive a class named Circle with another data member named radius. For this derived class, the x and y data members represent a circle’s centre coordinates. The member method of the Point class should consist of a constructor that set the value for x and y to 0, an area() method that return 0.
The derived class should has an override method named area() that return’s a circle area.
Area = 3.14 x radius2.
Draw UML diagram for the class Point and class Circle and then implement the class. Write a test program that creates one Point object and one Circle object with x 5, y 7 and radius 13. Display x and y for Point Object; x, y and radius for Circle Object.
2.
Create a class named Rectangle that contains data fields for height and length and a method named getArea() that returns the area of this Rectangle.
Create a child class (derived from Rectangle) named Cube. Cube contains an additional data field named depth, and a getArea() method that overrides the parent method.
Draw the UML diagram for the class (Class Rectangle and Class Cube) and then implement the class. Write a test program that creates one Rectangle object with height 4 and length 40 and one Cube object height 15, length 20 and depth 45.
Display height, length and area of each object.
Subscribe to:
Post Comments (Atom)
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. ...
-
ANSWERS TO CHAPTER EXERCISES (CHAPTER 8) Review Questions 1. List and describe various types of output, including technolog...
-
Based on real life scenario on any local company/ organization which you are very familiar, define the problem that could be addressed thr...
-
A. Response to the following statements by circling either T (TRUE) or F (FALSE). [10M] I. 1. Java enables users...
No comments:
Post a Comment