Answered step by step
Verified Expert Solution
Link Copied!

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.
2)(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 3.0, and 4.0 denote the width and height of a rectangle.
A no-arg 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:
p=2*(w+h)
A method named getArea() that returns the area of this rectangle. o Area: a=w*h
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 (3.0,4.0), the toString() method must return:
Rectangle: width =3.0 and height =4.0
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

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

Step: 3

blur-text-image

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

Semantics In Databases Second International Workshop Dagstuhl Castle Germany January 2001 Revised Papers Lncs 2582

Authors: Leopoldo Bertossi ,Gyula O.H. Katona ,Klaus-Dieter Schewe ,Bernhard Thalheim

2003rd Edition

3540009574, 978-3540009573

Students also viewed these Databases questions