Page 1 of 1

Consider a potential instance method named tallerThanWide that would return true if a Rectangle object has a height that

Posted: Thu Jul 14, 2022 2:17 pm
by answerhappygod
Consider a potential instance methodnamed tallerThanWide that would return true ifa Rectangle object has a height that is larger than itswidth, and false otherwise.
Now consider a potential instance methodnamed adjust that would take two integers specifying awidth and height and adjust the dimensions ofa Rectangle as needed so that its dimensions are at leastas big as the ones specified by the parameters. For example, ifa Rectangle‘s dimensions are 100 x 50, then callingthe adjust method with parameters of 80 and 70 wouldleave the Rectangle‘s width alone (because 100 is alreadygreater than 80), but change its height to 70 (because 50 issmaller than 70).
Consider the following client code — i.e., code from anotherclass that uses a Rectangle object:
Because our Rectangle class employs appropriateencapsulation, this code fragment will not compile.