Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Task 21: inheritance (is a) Aim: To define a subclass from a superclass through inheritance, to invoke the superclasss constructors and methods using the super

Task 21: inheritance (is a)
Aim: To define a subclass from a superclass through inheritance, to invoke the superclasss constructors and methods using the super keyword, and to override instance methods in the subclass.
Title: Point, Circle and Cylinder classes
Summary: be familiar with inheritance relationship and override concept.
Question: In this task, draw inheritance hierarchy and write a complete java codes that implements the new UML class diagram according to the relationship between the three classes:
Circle
-x : int
-y : int -radius : int
To do: +constructor
To do: +overload constructor +seX (x:int): void
+setY (y:int): void +setRadius (radius:int): void +getX ():int
+getY ():int
+getRadius ():int +getDiameter ():int +getCircumference (): double +getArea (): double +printInfo (): void
Cylinder
-x : int
-y: int -radius: int -height: int
To do: +constructor
To do: +overload constructor +seX (x:int): void
+setY (y:int): void +setRadius (radius:int): void +setHeight (height:int): void +getX ():int
+getY ():int
+getRadius ():int
+getHeight ():int +getDiameter ():int +getCircumference (): double +getArea (): double +getVolume (): double +printInfo (): void
Point
-x: int -y: int
To do: +constructor
To do: +overload constructor +seX (x:int): void
+setY (y:int): void
+getX ():int
+getY ():int
+printInfo (): void
In class
- - -
In class -
-
- -
Circle
Lab Sheet 9
A0312202 Object Oriented Programming Lab (JAVA)
getDiameter ( ) method implements as follow: 2*radius getCircumference ( ) method implements as follow: PI*2*radius getArea ( ) method implements as follows: PI*radius^2
Cylinder
getDiameter ( ) method implements as follow : 2*radius (Same Implementation-no need to write it)
getCircumference ( ) method implements as follow : PI*2*radius (Same Implementation-no need to write it)
getArea ( ) method implements as follow : 2 * + PI*2*radius*height getVolume ( ) method implements as follow : *height
PI*radius^2
PI*radius^2
You will also
1- 2- 3- 4- 5- 6- 7- 8- 9- 10- 11- 12- 13- 14- 15-
write a test program called Test. This will do the following:
Create an object of type Point with x=1 and y=3. Print the information of this object.
Change the value of x to be 6.
Print the new information.
Create an object of type Circle with x=1 and y=1 and radius=5. Print the information of this object.
Change the value of x to be 3.
Print the new information.
Create an object of type Cylinder with x=1 and y=2 and radius=4 and height =9. Print the new information.
Change the value of radius to be 6.
Print the new information.
Print Area of the cylinder.
Print Volume of the cylinder.
Print Circumference of the cylinder.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions