Answered step by step
Verified Expert Solution
Question
1 Approved Answer
You must keep the class name You must hold the naming conventions requested in this document All deliverables are defined at the end of this
You must keep the class name
You must hold the naming conventions requested in this document
All deliverables are defined at the end of this document. You must upload them as requested.
Class Name: Rectangle, Java File Name: Rectangle.java Design and write a Rectangle class that extends the GeometricShape class provided in the midterm test on Blackboard. The class contains:
Two double data fields called w and h with default values and denote the width and height of a rectangle.
A noarg constructor creates a default rectangle.
A constructor that creates a rectangle with the specified w and h
The accessor getter methods for both data fields.
The mutator setter methods for both data fields.
A method named getPerimeter that returns the perimeter of this rectangle. o Perimeter:
pwh
A method named getArea that returns the area of this rectangle. o Area: awh
A method named toString that returns a string description for the rectangle.
o For example, if we have a rectangle with the following width and height the toString method must return:
Rectangle: width and height
In the main method, write a testing program that prompts the user to enter the width and height of the rectangle, a colour, and a boolean value to indicate whether the rectangle is filled. The program should create a Rectangle object with the specified width and height and set the colour and filled properties using the input. The program should display the area, perimeter, colour, and true or false to indicate whether it is filled or not.
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