Free University of Bozen-Bolzano
Bachelor in Production Engineering
Introduction to Programming - A.A. 2004/2005

Exam exercise
Class PhotoGallery


We want to realize a Java class PhotoGallery that represents an online photo gallery. Each PhotoGallery has an url (represented by a string), and contains photos, each represented simply as a string that denotes the link to the actual photo. The maximum number of photos a photo gallery may contain is fixed the moment the photo gallery is created. The functionalities of the objects of the class are:


Part 1. Realize the class PhotoGallery.

Solution: representation of the objects, skeleton of the class, solution


Part 2. Realize a client class of the class PhotoGallery containing a static method readFromFile that takes as parameters a string f that represents a filename containing photos (i.e., strings) and a PhotoGallery g, and adds to g all photos present in the file f.

Solution


Part 3. Briefly discuss the difference between instance variables and local variables (with respect to initialization, lifetime, scope).