Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Define a class of rectangles. Please name your test program as RectangleTest How to hand in the assignment Follow the steps below: Complete the UML

Define a class of rectangles. Please name your test program as "RectangleTest"
How to hand in the assignment
Follow the steps below:
Complete the UML in a Microsoft Word document or other document file format,
and the programs in .java files. Once you are done, convert your UML file to a
PDF (.pdf).
Upload the .java files as well as the PDF document UML into Gradescope. Do
not submit a .docx file for the UML, first convert your file to PDF (.pdf).
Click "Upload".
I remind you that if you do not submit the assignment before the due date, you will not be
able to submit it.
Note: Your output should look exactly like the output below and should be able to
run test cases.
The width before is
The height before is
The width after is
The height after is
The area is
The perimeter is
Design a class named Rectangle. The class contains:height of the rectangle. The default values are 1.0 for both width and height.
> A no-arg constructor that creates a default rectangle.
> A constructor that creates a rectangle with a specified width and height.
> Two sets of get and set methods for the two private data fields.
> A method named getArea() that returns the area of a rectangle.
> A method named getPerimeter() that returns the perimeter.
Please make sure to follow this sequence of steps:
Draw the UML of the Rectangle class. The data fields should be private, and
constructors and all other methods should be public.
Implement the Rectangle class (name it "Rectangle") in Rectangle.java.
Implement the RectangleTest class (name it "RectangleTest") with the main
method in RectangleTest.java. It should do the following tasks:
Create a rectangle object with width 4.0 and height 40.0.
Change the rectangle's width to 5.0 and height to 50.0.
Print out the area of the rectangle.
Print out the perimeter of the rectangle.
Grading: This lab is worth 100 points. Out of 100 maximum points, the UML will
count for 20 points, the two source codes will count for 80 points.
Submission:
For this assignment, please name your class file as "Rectangle"
package homework;
image text in transcribed

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

Databases Illuminated

Authors: Catherine M Ricardo, Susan D Urban

3rd Edition

1284056945, 9781284056945

More Books

Students also viewed these Databases questions