Question: Implement the given UML. You have one interface called '_Area' and one abstract class called '_Shape'. Class '_Shape' will be used as a super class.

Implement the given UML. You have one interface called '_Area' and one abstract class called '_Shape'. Class '_Shape' will be used as a super class. Overide the methods toString, getArea and getName in all classes.

The area of the circle and triangle:

Circle Area = pi *r^2 Triangle Area = 0.5 * height * base

make a test class and . Make objects from class Circle , Triangle. Then assign all objects to array of type _Shape, iterate over the array and call toString of each object.

The out put should be like:

Class name is circle

Area =

Class name is triangle

Area=

Implement the given UML. You have one interface called '_Area' and one

> _Area + getArea() : Double implements Shape {abstract} - name : String + setName(String) : void + getName(): String + toString(): void Extends Extends Circle Triangle -radius: Double - base : Double - height: Double constructor Circle(r: Double) + getArea(): Double + setRadius(Double :r): void + getRadius() : Double + toString(): void constructor Triangle(Double : b, Double : h) + getArea() : Double + setBase(Double : b) : void + setHeight(Double : h) : void + getBase() : Double + getHeight(): Double + toString(): void

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!