Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create a class MYRectangle. MYRectangle class has 3 attributes: The first two are length and width, each of which defaults to 1 and private, and
Create a class MYRectangle. MYRectangle class has 3 attributes: The first two are length and width, each of which defaults to 1 and private, and the third is an object of class MyPoint representing the values of x and y. Class MyPoint contains a single constructor and two private instance variables, each of which defaults to 0 . The constructor in the MyPoint class takes two integer arguments. Suppose that you have the following statement which provides 28 and 86 as values for the arguments x and y : MyPoint originPoint = new MyPoint (28,86); The result of executing this statement can be illustrated in the next figure: - MyRectangle.java should include four constructors - MyRectangle ( ) : To construct a rectangle with origin point (0,0). - MyRectangle (MyPoint): To construct a rectangle with origin point specified by the parameter. - MyRectangle (int w, int h ): To construct a rectangle with origin point (0,0). The first parameter is the x - and y-coordinates of one point, and the next two are the width and height of the rectangle. - MyRectangle (MyPoint p, int w, int h ): To construct a rectangle with origin point specified by the parameter, and the next two are the width and height of the rectangle. MyRectangle.java should include these methods: - public void moveRectangle(int x, int y ) a method for moving the rectangle. - public int computeArea() a method for computing the area of the rectangle
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