Showing posts with label question. Show all posts
Showing posts with label question. Show all posts

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.

Monday, August 22, 2011

ICT 203 - Q1d (Foundations in Modern System Design)

Three classes should be coded, each with its instance variables (if applicable), constructor, and accessor methods. The question also guides that each subclass should have a computeFee() method, as coded below: Question

For OrdinaryMember class:

public double computeFee() {

double payment = 0;

if (getIsOverseas())

payment = getMembershipFee() * 0.5;

else

payment = getMembershipFee();

return payment;

}


For AssociateMember class:

public double computeFee() {

double payment = 0;

if (getIsOverseas())

payment = getMembershipFee() * 0.5;

else

payment = getMembershipFee();

payment = payment + magazineCharge;

return payment;

}

ICT 203 - Q1c

I would check the location of the associate member within the subscribeMagazine method in the Associate subclass to determine if the Associate Member is eligible to subscribe for the magazine. If the member is eligible to subscribe for the magazine, within the subscribeMagazine method, it will check to see if the member wants to subscribe for the magazine. If the member is eligible and wants to subscribe to the magazine, the value of the variable subscribeMagazine (true) is returned, else false will be returned. The value of the variable subscribeMagazine returned will be used in the computeFee method. If the value of variable subscribeMagazine is true, the additonalFee variable will be added in the calculation of the totalFee, else the additionalFee will not be added to the totalFee.

Question

ICT 203 - Q1b ( Foundations in Modern System Design)










Question

ICT 203 - Q1a ( Foundations in Modern System Design)

Classes involved would be the superclass called Membership, and the subclasses Ordinary and Associate. The superclass Membership would be an abstract class with its common (generic) attributes such as memberName, address and totalFee, and methods such as computeFee(), which would be inherited and reused by the Ordinary and Associate subclasses. Thus, the Ordinary and Associate subclasses have a “is a” relationship with its superclass Membership.

Question

ICT203 - Foundations in Modern System Design Question 1

An employees’ union has two types of membership: ordinary and associate. Ordinary members pay $108 per year and receive a free monthly magazine. Associate members pay $72 per year, but they do not receive the magazine unless they pay an additional charge of $12 per year. Every  member gets a 50% discount off the membership fee, if he is stationed overseas; however, this discount is not applicable to the magazine charge for the associate member as the union does not send the magazine to associate members overseas.
(a) Identify the classes involved and explain the superclass-superclass relationship among  them. (answer)

(b) Draw a UML class diagram to depict the given information, showing the attributes for each  class, and the class hierarchy. (answer)

(c) Explain how you would record the fact that an associate member needs to pay for the  magazine. State also the class or classes concerned, and the attributes and/or methods added. (answer)

(d) Write Java code to define the classes and hierarchy you had identified above. In each class, include the attributes as instance variables of suitable data types, and appropriate  constructor(s) that initialize(s) the instance variables. Note that each subclass should have  its own implementation of the computeFee() method. (answer)

(e) (i) Explain how you might write the computeFee() method for the superclass.

(ii) What is the advantage of having this method in the superclass?


Related Posts: