Saturday, February 11, 2012

ICT203 - Foundations in Modern System Design Question 2

(a) Collection classes are to be used to model a number of real world situations, described in (i) to (iii) below. In each case:
  • write down the name of the class that you think is most suitable;
  • give a brief justification for your choice (no more than one or two sentences);
  • write down an expression or expressions to create an instance of the collection class you have chosen, assign it to a suitably named variable, and add the example elements given in the description to the collection.

(i) An ICT203 tutor wants to store her students' myUni names as strings in such a way that she can easily look up an individual student, as in the table below. There are no two students in her group with the same name.

Student’s name      |      myUni name      
Charlie Dickens             Charles Dickens
Margie Hector               Margaret Hector
Terry Martin                  Terence Martin

(ii) When a hotel is fully booked, it holds a waiting list of customers in case of cancellations. Once a cancellation is received, the newly available room is allocated to the first person on the waiting list, who is then deleted from the list. On a particular day the first three customers added to the list are Ali Baba, Bibi Batek and Charlie Chan.

(iii) A video shop wants to store the titles of videos available for hire. It must be possible to list all the titles available but no particular order is required. Although the store may have more than one copy of a particular film, the title should only appear once. Titles available include: Iron Man, Crystal Skull and Dr Doplenty.

(iv) A property company has a block of luxury apartments for sale. The apartments comes in three models: modelA, modelB and modelC. During the year of its launch, it achieved the quarterly sales (in units) as shown in the table below:

(b) A hash map is to be used to store the addresses of students on a Uni course.

(i) The designer of the software needs to decide what to use as keys for the hash map, and considers student names and personal identifiers as possible candidates.  If you were designing the hash map, which of these would you choose? Briefly justify your answer.

(ii) During the discussions about the software to be used it becomes apparent that there
may be more than one student at the same address.  Would this affect your choice of a hash map as the appropriate collection class to use? Briefly justify your answer.

(c) Page 12 of Unit 3 shows how an Iterator object could be used to directly retrieve all the objects in a collection for further processing.  Using an appropriate example, explain whether this could be applied to a HashMap object.

No comments:

Post a Comment