Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Needs help, stuck in the middle For this question, you must write a java class called Rectangle and a client class called RectangleClient. The partial

Needs help, stuck in the middle For this question, you must write a java class called Rectangle and a client class called RectangleClient. The partial Rectangle class is given below. (For this assignment, you will have to submit 2 .java files: one for Rectangle class and the other one for RectangleClient class.) // A Rectangle stores an (x, y) coordinate of its top/left corner, its width and height. public class Rectangle { private int x; private int y; private int width; private int height; // constructs a new Rectangle with the given intX, intY and inSideLength public Rectangle(int X, int Y, int Width, int Height) // returns the fields' values public int getX() public int getY() public int getWidth() public int getHeight() public int getArea() public bool IsSquare() // returns a string such as Rectangle located at (1,2) with dimensions 3x4 and area 49., where 3 is width, 4 is height and 12 is the area. public String toString() ... } Implement constructor from the code snippet. Implement getter methods for the rectangles coordinates and dimensions. Implement an instance method called getArea().

This method should computeand return area of a rectangle.

Implement an instance method called square. This method should return true if the width of the rectangle is equal to its height, and false otherwise. Write the client class RectangleClient that creates an object of class Rectangle and initializes its x, y, width and height to 11, 12, 3, and 4 respectively. Print out information about the object using System.out.println() method. Your program should produce the following output: Rectangle located at (11,12) with dimensions 3x4 and area 12.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions