Free University of Bozen-Bolzano
Faculty of Computer Science - Bachelor in Applied Computer Science
Introduction to Programming - A.A. 2004/2005
(new study plan - 8 CFU)

Written Exam 7/6/2005

A ski rental company needs to keep track of the skis that are being rented in various cities.

Part 1. (4 points) For each Ski object, the information of interest is:

Realize a Java class Ski, to represent Ski objects, that exports the following functionalities:

Solution: class Ski

Part 2. (16 points) For each city (identified by its name, a string), the skis available in that city are stored in a SkiPool data structure. Realize a Java class SkiPool, to represent SkiPool objects, that exports the following functionalities:

In the proposed solution, you have to take into account that there is no bound on the number of skis that can be in a SkiPool. If you use arrays to represent the collection of skis, you should handle the recovery of unused memory.

Solution: representation of the objects, skeleton of the class, class SkiPool, class SkiPoolException

Part 3. (6 points) Realize a static method brandsforHeight, client of the class SkiPool (i.e., external to such a class) that, given a SkiPool object sp, a positive integer h representing the height of a person, and the name f of a file, writes on the file f the brands of all those skis in sp that are suitable for height h. The method should handle exceptions due to input/output errors that may occur.


Additional files to test the solution: class Main, input file skis.txt

Part 4. (4 points) Discuss the types of errors that a program may contain, and give for each of them an example in terms of a (fragment) of Java program.