For each of the following situations,
- write down the name of the collection class you think is most suitable model;
- give a brief justification for your choice;
- write Java code 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 of the collection.
(a) A registrar needs to organize the attendees of a course in alphabetical order. As participants register for the course, they are placed automatically in ascending order of their names. Mary Jane, John Doe and Ali Ahmad are the first 3 participants to register for the course
(b) The patrons waiting at a very popular eatery are given a queue number upon arriving at the eatery when all the tables are occupied. The eatery may serve patrons in a sequence that does not follow the queue number due to special reasons (eg premium member, or different sized table available etc). The patrons are called by a number displayed at the waiting area. The first 3 families waiting for a seat are the Lees, the Wongs and the Tans.
(c) An online shopping site wants to keep track of its members and their delivery address. At any point in time, when the member makes payment, the system can automatically retrieve the delivery address. “Mary” (userID mary77) living at “67 Jalan Perminpin”, “Jane” (userID prettyGal88) living at “64 Woodlands Drive” and “John” (userID johnXYZ) living at “8 Sims Drive” are three members of the online site.
Summary: This question belongs to modern systems design and discusses about a serving company’s operations and hierarchies among the classes.
Total word count: 480
Download Full Solution