Question
Shape.java Abstract class called Shape declare public member variables width of type double height of type double declare and implement a method called setSize 2
Shape.java
Abstract class called Shape
declare public member variables
width of type double
height of type double
declare and implement a method called setSize
2 parameters: width, height of type double
This method sets/initializes the member variables width and height
declare an abstract method called getArea
The return type of this method should be double
No parameters
--------------------------------------
Rectangle.java
Rectangle class inherits members of Shape class
This class has only one method called getArea
getArea method should return the area of a rectangle
---------------------
Triangle.java
Triangle class inherits members of Shape class
This class has only one method called getArea
getArea method should return the area of a triangle
-------------------------------
Driver.java
main method
Declare/init a new object of type Triangle
Declare/init a new object of type Rectangle
Declare an object of type Shape and assign it to the the triangle object
Using the Shape object, call setSize method providing arguments width/height
Reassign the shape object to the rectangle object
Using the Shape object, call setSize method providing arguments width/height
Using the triangle object, print out the area of the triangle by calling getArea()
Using the rectangle object, print out the area of the rectangle by calling getArea()
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