// version 1
class Library {
Enumeration getTitlesSortedByAuthor(CallNo start, CallNo end);
}
// version 2
class Library {
Title[] getTitlesSortedByAuthor(CallNo start, CallNo end);
}
Discuss the relative benefits and shortcomings
of each approach (if any),
referring to software qualities and principles.
Assume that the sumMaxAndMin method is invoked elsewhere in the program with this statement: System.out.println(sumMaxAndMin(i, j, k));, where i, j, and k are integers.
int sumMaxAndMin(int x1, int x2, int x3)
{
boolean med1 = false, med2 = false, med3 = false;
if ( (x2 >= x1 && x1 >= x3) || (x2 <= x1 && x1 <= x3) )
med1 = true;
if ( (x1 >= x2 && x2 >= x3) || (x1 <= x2 && x2 <= x3) )
med1 = true;
if ( (x2 >= x3 && x3 >= x1) || (x2 <= x3 && x3 <= x1) )
med3 = true;
if (med1)
return x2+x3;
if (med2)
return x1+x3;
if (med3)
return x1+x2;
}