Question: A0312202 Object Oriented Programming Lab (JAVA) Task 21: inheritance (is -a) Aim: To define a subclass from a superclass through inheritance, to invoke the superclass's

A0312202 Object Oriented Programming Lab (JAVA) Task 21: inheritance (is -a) Aim: To define a subclass from a superclass through inheritance, to invoke the superclass's 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: Point Circle Cylinder -x : int -x: int -X:int -y: int -y:int To do: +constructor To do: toverload constructor tsex (x:int): void tsety (y:int): void +getX(:int + get Y 0:int #printInfo(): void -radius: int To do: +constructor To do: +overload constructor tsex (x:int): void +setY(y:int): void #setRadius (radius:int): void +getX():int tgetY():int +getRadius 0:int +getDiameter :int getCircumference (): double +getArea (): double printInfo(): void -radius: int -height: int To do: tconstructor To do: overload constructor *sex (x:int): void *sety (y:int): void #setRadius (radius:int): void *setHeight (height:int): void #getX() int getY0:int *getRadius (:int +get Height (int +get Diameter (sint #getCircumference (): double *get Area (): double +get Volume (): double *printInfo(): void A0312202 Object Oriented Programming Lab (JAVA) Notes: In class Circle getDiameter () method implements as follow: 2*radius getCircumference () method implements as follow: PI*2*radius getArea() method implements as follows: PI*radius^2 In class Cylinder getDiameter 4 method implements as follow: 2*radius (Same Implementation-no need to write it) getCireumferenee method implements as follow : P1*2*radius (Same Implementation-no need to write it) getArea () method implements as follow :2. Pl*radius^2+ PI*2*radius*height getVolume method implements as follow : Pl*radius 2*height You will also write a test program called Test. This will do the following: 1- Create an object of type Point with x=1 and y=3. 2- Print the information of this object. 3. Change the value of x to be 6. 4- Print the new information. 5- Create an object of type Circle with x=1 and y=1 and radius=5. 6- Print the information of this object. 7- Change the value of x to be 3. 8- Print the new information. 9. Create an object of type Cylinder with x=1 and y=2 and radius=-4 and height 9. 10- Print the new information. 11- Change the value of radius to be 6. 12- Print the new information. 13- Print Area of the cylinder 14- Print Volume of the cylinder. 15- Print Circumference of the cylinder
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
