Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning ASP.NET 4.5 Databases

Authors: Sandeep Chanda, Damien Foggon

3rd Edition

1430243805, 978-1430243809

More Books

Students also viewed these Databases questions

Question

=+1 What would you do if you were the IHR manager?

Answered: 1 week ago