To implement a rectangle class which stores its position


Question: To implement a Rectangle class which stores its position and size, you could use four integer instance variables x, y, width, height or you could use four Point instance variables that store the coordinates of the four corners of the rectangle.

a. Which of these two implementations is better and why?

b. Suppose the Rectangle has a method that allows it to be rotated by an arbitrary angle. In that case, the first implementation is insufficient, but what about the second implementation? Is it a reasonable implementation in this case?

c. Come up with a third better implementation in the case where the Rectangle can be rotated.

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: To implement a rectangle class which stores its position
Reference No:- TGS02580229

Expected delivery within 24 Hours