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=
> _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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started