ITI 1121 Midterm: ITI 1121 University of Ottawa 2011 Midterm-en

28 views13 pages

Document Summary

For this question, n items are stored into k boxes. You can assume that weights and map are not null, and the content of both arrays is valid. A tuple holds two integer numbers (objects of the class integer). All the tuples have a method getfirst, as well as a method getsecond, returning a reference to the rst, and second, number of the tuple, respectively. A tuple has a method isincreasing that returns true if the rst element is smaller than the second element, and false otherwise. For this question there is an interface named tuple, an abstract class named abstracttuple, and two concrete implementations, called pair and arraypair. Their complete description can be found on the next pages. An object of the class integer has a method intvalue that returns the value of the object as an int. The execution of the statements below produces the following output: