Question: You have been given an incomplete class called Shape. Complete the following steps. Complete the Shape class by including a getter and setter for its

You have been given an incomplete class called Shape. Complete the following steps.
Complete the Shape class by including a getter and setter for its attribute
Create two new child classes, Rectangle and Triangle. These child classes should both have an additional attribute called height. Create constructors, and getters and setters.
Create a new method in Rectangle and Triangle called getArea(). This method should return the area of each shape
The area of a rectangle is width x height, and the area for a triangle is (width x height)/2
Inside the main method, create both a Triangle and a Rectangle, and print the area of each.
You have been given an incomplete class called

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 Programming Questions!