Given below is a Rectangle class consisting of an upper left coordinate and a lower right coordinate. class Rectangle { int upperLeftX; int upperLeftY; int lowerRightX; int lowerRightY; } Since the upper left coordinate and lower right coordinate comprise of points, how would you modify the definition of the Rectangle class to include these points in your class? write a complete java code to do this , not only the classes. Hint: You can create a Point class to store the x and y coordinates of the upper left and lower right points and use composition to include the upper left and lower right points inside the Rectangle class, as objects of the Point class.
Write a full java code with input out example in OOP style that does the following:
Given below is a Rectangle class consisting of an upper left coordinate and a lower right coordinate.
class Rectangle { int upperLeftX; int upperLeftY; int lowerRightX; int lowerRightY; }
Since the upper left coordinate and lower right coordinate comprise of points, how would you modify the definition of the Rectangle class to include these points in your class?
write a complete java code to do this , not only the classes.
Hint: You can create a Point class to store the x and y coordinates of the upper left and lower right points and use composition to include the upper left and lower right points inside the Rectangle class, as objects of the Point class.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps