Premium Resources

We know the secret of your success

M256/C Software development with Java Undergraduate Level Course Examination 2018

$39.00

PAPER TITLE: SOFTWARE DEVELOPMENT WITH JAVA

DATE: Friday, 21 September 2018

 

PART 1

 

Question 1         Which two of the following statements about software development are true? (Select two options)

  1. An initial structural model of a system is a static model that illustrates the state of the system at a particular time.
  2. Javadoc is an example of a design tool.
  3.  The Waterfall method is an example of an adaptive software development method.
  4.  A common practice in iterative software development is to restrict the initial development to a small subset of the requirements of the system.
  5.  Enhancing the system by adding extra facilities is part of the maintenance phase.

 

ANSWERS(Purchase full paper to get all the solution)

4A common practice in iterative software development is to restrict the initial development to a small subset of the requirements of the system. 

5. Enhancing the system by adding extra facilities is part of the maintenance phase.

 

Question 2         Based on the information above which two of the following statements are true? (Select two options)

A.    The diagram shows that team12 and team3 are linked to fixture3 via different associations.

B.    The diagram shows how team12, team3 and fixture3 interact.

C.     The diagram shows a collaboration between team12 and fixture3.

D.    The diagram shows that team12 has an attribute ”Brown Bears”

E.    The state of fixture3 includes the homePoints attribute value 15.

 

Question 3         Which two of the following statements relating to the requirements specification process are true? (Select two options)

  1.  The requirements document may include details of the budget.
  2.  The following is an example of a non-behavioural constraint: ‘The memory requirements of the software must not exceed 5TB.’
  3.  Requirements creep can be avoided by employing a methodology of iterative prototyping.
  4.  The main goal of requirements analysis is to make the requirements document as general as possible in order to reduce constraints on the developer.
  5.  The following is an example of an acceptance test:

‘The software should implement each ward list as an indexed list.’

 

 

Question 4         Which two of the following statements about conceptual modelling are true? (Select two options)

  1. A recursive association is one via which an object of one class may be linked to more than one object of another class.
  2. The term invariant means an attribute of a conceptual class which has a constant value for all objects of that class.
  3. A relationship that is not a generalisation and involves three or more classes can be modelled by a single class that has associations with each of the classes involved in the relationship.
  4. The conceptual model gives rise to the initial structural model.
  5. If class Q and R are specialisations of class Y then class Y must be an abstract class.

 

 

Question 5         The following is an extract from a requirements document for a system for a yoga school. The incomplete class diagram below forms part of a conceptual model for the system.

Each yoga class is led by one yoga instructor and each yoga instructor leads between one and ten yoga classes.

Based on the information above, which three of the following statements are true? (Select three options)

  1.  Each Pupil object is an instance of a child class of Pupil.
  2.  If a Pupil object aPupil is linked to two YogaClass objects aYogaClass and bYogaClass, then aYogaClass and bYogaClass must be linked to the same Instructor object.
  3.  The multiplicity of the leads association at the YogaInstructor end should be 1.
  4.  The multiplicity of the leads association at the YogaInstructor end should be 1..10.
  5.  The class Beginner generalises the class Pupil.
  6.  It is possible for a Beginner object to be linked to a YogaClass object.

 

Question 6         The following is an extract from a requirements document for a University administration system. The incomplete class diagram below forms part of a conceptual model for the system.

An academic belongs to a single faculty and may be mentored by other academics who must be in the same faculty.

Figure 3

Based on the information in Figure 3, which two of the following statements are true? (Select two options)

  1.  An academic can have no more than 3 mentors.
  2.  An academic can have any number of mentors including no mentor.
  3.  The following is an invariant that is required in addition to the class diagram, as part of the conceptual model:

If aStudent and bStudent are Student objects that are linked to the same Faculty object then aStudent and bStudent must be linked to the same Academic object.

  1.  The multiplicity of the isStaffMemberOf association at the Faculty end should be 0..1.
  2. mentors is a recursive association.

 

 

Question 7         Which two of the following statements are true? (Select two options)

A.    Coupling is a measure of how strongly related and focused the responsibilities of a component are.

B.    A method’s post-condition states what the method must achieve regardless of whether the pre-condition is satisfied or not.

C.    It is often possible to identify some of a method’s pre-conditions from the Javadoc specification of the exceptions that the methods throw.

D.    If there is no explicit modifier in front of a member of a Java class then the member cannot be accessed from outside the class’s package.

E.    A method’s pre-condition should state what invoking the method achieves.

 

Question 8         Which two of the following statements about object orientated software development are true? (Select two options)

1. One benefit of component-based software development is that implementation errors are separated from specification errors.

  1.  To prevent privacy leaks from a component, no getter methods should be specified for the attributes of the classes within the component.
  2.  A benefit of design with reuse is that maintenance of the operational system is made easier.
  3.  Polymorphism provides a basis for protecting the integrity of objects.
  4.  When a class B is reused by composition by another class C, this is achieved by each instance of B having an instance of C as part of its state.

 

Questions 9 to 11 are based on the following information.

The incomplete class diagram below is part of a structural model being developed for a dental practice system.

It is followed by a use case description, and a walk-through and an incomplete sequence diagram for a particular scenario of that use case.

DentalCoord is the coordinating class and the coordinating object is surgery. Dental practice staff include a number of dentists and hygienists and these are the only dental staff relevant for this system. The attribute procedure in class Appointment is of user-defined type Procedure which is restricted to taking the three values CLEAN, CHECKUP, TREATMENT. The attribute name of the class Client and the attribute name of the class StaffMember are of the user-defined type Name.

Figure 4

Use case: List a member of dental staff’s appointments and clients for a given procedure

The receptionist identifies a member of dental staff and provides a procedure. For each appointment for that procedure to be taken by that staff member, the system displays the date of the appointment and the name of the client who made the appointment.

Walk-through:

Given: the StaffMember object dentist4, and the procedure CHECKUP:

  1. Access the collection of Appointment objects linked to dentist4, which in this case is {appointment1, appointment7,appointment8}.
  2. Create a new empty collection, results.
    For each Appointment object, anAppointment, accessed in step 1:
         3. get its procedure value;

If its procedure value is CHECKUP,

4. access the Client object, aClient, linked to anAppointment;

5. add (anAppointment, aClient) to results

    6. Return results

 

Incomplete sequence diagram (some messages answers replaced by letters P,Q,X,Y,Z

Question 9         Which one of the following statements could be a correct identification of the missing text indicated by the labels X, Y and Z in the sequence diagram shown in Figure 5? (Select one option)

A.        X is CHECKUP; Y is TREATMENT; Z is (appointment8, client9)
B.        X is TREATMENT; Y is CHECKUP; Z is client9
C.        X is CLEAN; Y is CLEAN; Z is client17
D.        X is CHECKUP; Y is CLEAN; Z is client17
E.        X is CHECKUP; Y is TREATMENT; Z is client9
F.        X is CHECKUP; Y is CHECKUP; Z is client9
 

Question 10       On the basis of the information provided in Figures 4 and 5 which two of the following statements are true? (Select two options)

A.    It is possible to create a sequence diagram that corresponds to the given walk-through and has no messages sent by dentist4.

B.     Figure 5 shows step 2 of the walk-through is carried out by Dentist.

C.    Figure 5 shows step 2 of the walk-through is carried out by surgery.

D.   Figure 5 shows step 3 of the walk-through is carried out three times.

E.    Figure 5 shows step 4 of the walk-through is carried out three times.

F.    Figure 5 shows step 4 of the walk-through is carried out by dentist4.

 

Question 11       On the basis of information provided in Figures 4 and 5 and the walkthrough, which two of the following statements is true? (Select two options)

A. A method whose specification begins as follows is appropriate for the protocol of Client: Client getClient()

B.  The association hasAppointments needs to be navigated from  DentalCoord to StaffMember

C.    A method whose specification begins as follows is appropriate for the protocol of Appointment: Client   getClient()

 D.   A method whose specification begins as follows is appropriate for the protocol of DentalCoord:

Map getAppointmentsAndClients(Dentist aDentist, Procedure aProcedure)

E.   The association takes needs to be navigated from StaffMember to Appointment

F.     The association makes needs to be navigated from Client to Appointment   

 

Question 12       Which two of the following statements about designing software are true? (Select two options)

  1.  If the coordinating class does too much work then the cohesion of the core system classes may be reduced.
  2.  When a one-way link is removed the object at one end must be destroyed.
  3.  When creating links of a two-way association, an object of the class at one end of the association should, if possible be made responsible for managing the process.
  1.  An object which initiates a cascade of messages is termed an information expert.
  1.  An invalid scenario is a scenario in which a post-condition is not met.

 

Question 13       Which two of the following statements about detailed design and implementation are true? (Select two options)

  1.  An enumerated type may be used to implement an instance variable which has an infinite number of possible values.
  2.  Assigning an immutable object to an instance variable prevents the value of the instance variable from being changed.
  3.  A utility class is a helper class that is only intended to be used within the system for which it was developed.
  4.  Refactoring can result in the creation of additional classes.
  5.  A compareTo() method should be specified for each class whose objects have a natural ordering that is to be used when storing them in sorted collections.

 

Question 14       Which two of the following statements about implementation and testing are true? (Select two options)

  1.  Test suites can be used in regression testing.
  2.  Verification is concerned with checking that all aspects of the system are consistent with the customer’s requirements.
  3.  Regression testing is only carried out while the system is being developed.
  4.  Testing that problems do not arise from the interaction of a system’s components is termed unit testing.
  5.  Black box testing is testing in which a method is tested against its specification, without any examination of code.

 

Question 15       Which two of the following statements about the M256 approach to implementing software in Java are true? (Recall that in M256 the first code iteration is the first stage in implementing a core system.) (Select two options)

  1.  Derived attributes should be implemented in the first code iteration.
  2.  An implementation model may be used as a blueprint for coding the core system.
  3.  The coordinating method for each use case is normally implemented in the first code iteration.
  4.  Normally, only the dynamic part of the implementation model is used by the developer when adopting a use case driven approach to implementation.
  1.  Instance variables representing link references should not be implemented in the first code iteration.

 

Question 16       Which two of the following statements about user interfaces and their design are true? (Select two options)

  1.  A user interface metaphor should typically be independent of users’ mental models.
  2.  Affordance refers to the extent to which a widget’s purpose is apparent.
  3.  In usability testing, determining the time taken to complete a task can contribute to the evaluation of the effectiveness of a prototype interface.
  4.  User interface metaphors can enhance the visibility of widgets by exploiting the familiar mental models of users.
  5.  A design heuristic is a rule of thumb that may not always be applicable, but is frequently useful.

 

Question 17       Which two of the following statements about user interfaces and their design are true? (Select two options)

  1.  Visibility refers to the manipulations that a widget appears to allow.
  2.  One aspect of direct manipulation is that small operations can be used to incrementally cause an overall big effect.
  3.  Think-aloud is an example of a usability testing technique.
  4.  A user-centred approach is focussed on optimising the satisfaction of all users of an interface.
  5.  A socio-technical system is a system which, once started, requires user input at pre-defined stages.

 

Question 18    Which two of the following statements about building a graphical user interface (GUI) using the M256 approach are true? (Select two options)

  1.  The core system must have a reference to some objects in the GUI.
  2.  Coordinating messages are not the only kind of messages that a user interface may send to core system objects.
  3.  When developing a GUI, the implementation stage includes determining what kinds of information should be displayed on each screen.
  4.  Acceptance testing is carried out in order to test the usability of the GUI.
  5.  Listeners are Java objects that are attached to interface components to initiate the handling of user interactions with the interface.

 

Question 19       Which two of the following statements are true? (Select two options)

  1.  Timeboxing is a key element of the rapid application development (RAD) method.
  2.  In a classic three-tiered architecture, the middle tier is normally the coordinating object.
  3.  Waterfall methods are examples of agile development.
  4.  Concurrency control is the regulation of access to shared data.
  5.  The Publish-Subscribe pattern is a creational design pattern and describes a design in which a new instance of a class is created only if an instance of the class does not already exist.

 

Question 20       Which two of the following statements are true? (Select two options)

  1.  The Façade design pattern describes a solution to the following problem:

Exactly one instance of a class is required.

  1.  A network architecture is concerned with how the software components in the overall system are connected and work together.
  2.  In M256, the GUI is an example of an instance of a façade class.
  3.  The Publish-Subscribe pattern can be used to keep interfaces up to date in a multi-user system.
  4.  In a tiered architecture the storage tier is also known as the back end of the system.


 

 

PART 2

This part contains four questions, each worth 20 marks. You should attempt three of these questions.

Question 21   (20 marks)   The following is an extract from a requirements document for a part of the  administration system for a motor racing club. This part of the system keeps track of existing club members and future driving lessons and car hires.

System domain

There are two types of member: students and instructors. Students are at one of two levels, “regular” or “advanced”. The level of a student determines the type of car that they are allowed to drive: regular students are permitted to drive only sports cars, whilst advanced students may drive any type. Instructors are assigned up to twenty students. Each student is assigned to a single instructor. Any member can book a lesson or make a reservation to hire a car. A member can book any number of lessons but can make no more than five reservations to hire cars. A student’s lesson is always given by the instructor to whom the student is assigned. An instructor can book a lesson to be given by any other instructor. Lessons are one hour long, start on the hour and are charged at the fixed hourly rate of the instructor giving the lesson. There is no vehicle charge for a lesson. Reservations for hire are for a day. The charge for a hire is the fixed daily rate for the car. Sports cars may be driven on public roads and therefore must display a registration number. Racing cars are of various categories: for example “Formula 2”, “Formula 3”. Racing cars do not have registration numbers.

No information about lessons or hires that have already taken place is kept by this system.

Use cases

Record new lesson. The user supplies the date and start time of the lesson. The user identifies the member booking the lesson, the instructor giving the lesson and the car the lesson will be in. If the member is a student, the car type must be appropriate to the student's level and the instructor giving the lesson must be the instructor assigned to the student. If the member is an instructor, the instructor giving the lesson must be a different instructor. If, for either of the members or for the car, there is already a reservation recorded for the given date or a lesson recorded for the given time and date, then the system informs the user. Otherwise the system records the lesson’s date, start time and charge, and that it is booked by the given member and provided by the given instructor in the given car.

Display member’s reservations. The user identifies the member. If the member has made any reservations for hires, then the system displays for each reservation the following information:

the name of the member and the date the reservation is for; the registration number of the car, if it is a sports car;

the category of the car, if it is a racing car; and the charge for the hire

  1. Explain why it is appropriate to use a class to model the event of a member hiring a car. (2 marks)
     

    Note that in this question you are dealing with a conceptual model. You will lose marks for including in your answers anything that is not relevant for a conceptual model.

    Figure 6 is an incomplete class diagram for a conceptual model with four classes unnamed and all the associations omitted.

    Figure 6

  2. Copy this incomplete diagram in Figure 6 into your answer book. Identify the four missing classes and put appropriate names for them into the four blank rectangles in your diagram. (2 marks)
     
  3.  (i) Now complete the class diagram for the conceptual model that you began in (b).(8 marks)
    (ii) Write the class descriptions required for a conceptual model for the system. This should involve the classes in Figure 6 above, along with the classes identified in your solution to part (b), and no other classes. You should omit all comments. (6 marks)
  4. State an invariant that should be included in your conceptual model to express the constraint that a student’s lesson is always given by the instructor to whom the student is assigned. (2 marks)

 

 

 

Question 22  (20 marks)     The following unfinished class diagram is a part of a structural model being developed for a small airline administration system.

Figure 7

Invariants

  1. For each Flight object, the value of its numFreeSeats attribute is equal to the value of its capacity minus the number of Booking objects to which it is linked.
  2. For each Flight object, the value of its numFreeSeats attribute is not negative.
  3. No two Booking objects linked to the same Passenger object can be linked to the same Flight object.

The following is a description of one of the use cases for this system.

Note that each booking is for only one passenger for one flight.

Cancel a booking

The user identifies a passenger and a flight. The passenger must have a booking for the flight. The booking that is to be cancelled and all information about it is removed from the system.

The object diagram in Figure 8 shows the relevant objects and links for a particular scenario of the use case, before the use case is initiated. Attributes that are not relevant to the question have been omitted.

  1. Draw an object diagram showing the relevant objects and links after the use case has completed, with the identified objects being passenger2 and flight4. Only attributes whose values have changed need to be shown. (2 marks)
     
  2. Write out a formal specification for the coordinating method, as follows. You should use cancel for the name of the method and you should give the method header (i.e. the return type, method name and any argument(s) and their type(s)), any pre-condition and the post-condition. (4 marks)
     
  3. Consider the following incomplete walk-through for the scenario above for cancelling a booking where the identified Passenger object is passenger2 and the identified Flight object is flight4.
    Given: the Passenger object, passenger2 and the Flight object flight4.
    1. Access the collection of Booking objects linked to passenger2, which in this case is {booking5, booking9}.
    For each Booking object, aBooking,accessed in Step 1:
              2. Access the Flight object, aFlight, linked to aBooking.
             3. Check whether aFlight is flight4
    Since step 3 succeeds for booking9
    . . .


    (i) Identify all the navigations required for the first three steps of the walk-through. Some of the required navigations may already be shown in the class diagram in Figure 7. For each navigation that you identify, write down the name of the association and the direction in which it needs to be navigated.

    (ii)Complete the above walk-through. Write down the remaining steps as your answer in the answer booklet. (5 marks)
  1. Complete the following sequence diagram for the above scenario, based on the walk-through above. Note that airline is the coordinating object. Annotate the diagram with numbers to indicate where each walk-through step is achieved.

Give the complete sequence diagram in your answer book.

e. Now consider the following scenario for the same use case. The object diagram represents the situation before the use case is initiated.

Write down the remainder of the walk-through for this scenario. (2 marks)

 

 

 

 

Question 23  (20 marks)      Consider the class diagram in Figure 11 and class descriptions, extracted from an implementation model for a system to assist a company in managing its stock control so that it can fulfil its orders: the Stock Control System. Then answer part (a) which follows. You are advised to read the questions first and then refer to the extract from the implementation model in order to answer them. Note that this question contains five parts in all. The last four parts, (b), (c), (d) and (e), are based on dynamic models which are given later.

The Figure 11 class diagram and following class descriptions are part of an implementation model for the Stock Control System. Classes, attributes, links and methods that are not relevant for this question have been omitted.

  1. Table 1 sets out a test case specification for a test of the method addOrderItem(anOrder, aProduct, aQuantity) in the class StockCoord.

Read the table and the following notes and then write the body of a JUnit test method test1AddOrderItem corresponding to the test case specification

Notes:

Your answer should consist of the body of the test method, not including the header

You should assume that except for the method being tested all methods specified in the given extract from the implementation model have already been implemented and tested.

You can use any valid values for attributes that are not specified in Table 1. You are not required to provide Javadoc, or any other comments. (7 marks)

One use case in the Stock Control System is the following:

Add Order Item

The user identifies a product and an order and provides a quantity to be ordered. If the provided quantity is at least 1 and the quantity of the product in stock is not less than the provided order quantity, the system records that an order item for that quantity of the product has been added to the order and decrements the stock level of the product by the quantity ordered. If the provided quantity is less than 1 or the quantity of the product in stock is less than the provided quantity ordered, the system displays an appropriate message.

The following are dynamic models for a design for the above use case. Use the scenario illustrated in the object diagrams in Figures 12 and 13 and the walk-through, and sequence diagram in Figure 14 for the scenario to answer parts (b), (c), (d) and (e) which follow. The coordinating object is called controller.

 

 

Walk-through for the above scenario:

Given: the Order object, order3, the Product object, product11 and the order quantity 2.

  1. Check whether the order quantity is greater than 0 As the check succeeds:
  2. Get the value of the stockLevel attribute of product11 which in this case is 19.
  3. Check that the stockLevel value is greater than or equal to the order quantity.

As the check succeeds:

  1. Create orderItem12, a new OrderItem object, with number value 2.
  2. orderItem12 records a reference to product11.
  3. Decrement the value of the stockLevel attribute of product11 by the order quantity which in this case is 2.
  4. Get the value of the price attribute of product11, which in this case is 300.
  5. Calculate the cost for orderItem12 by multiplying the price attribute of product11 by the order quantity which in this case gives 600.
  6. Set the cost attribute of orderItem12 to the cost calculated in step 8.
  7. order3 records a reference to orderItem12.
  8. Increment the value of the totalCost attribute of order3 by the value of the cost attribute of orderItem12 which in this case is 600.
  9. Return true.

 

  1. Suggest a suitable order for implementing the methods and constructor required for the design of the use case Add Order Item. (Note that as the specified OrderItem constructor is quite complex, it would not be implemented as part of the first code iteration, but as part of implementing the Add Order Item use case.)

You should not include methods that would be implemented in the first code iteration and should only include methods that are specified in the class descriptions. Do not include additional methods that might be needed for testing. Specify the class and name for each method. (4 marks)

  1. Write code for the method getCostOfAndRemove(aQuantity) of the class Product according to the specification and design given in the implementation model. You are not required to provide the method header or Javadoc comments. (2 marks)
  2. Write code for the OrderItem constructor OrderItem(anOrder, aProduct, aQuantity)according to the specification and design given in the implementation model. You are not required to provide the method header or Javadoc comments. (3 marks)
  3. Write code for the method addOrderItem(anOrder, aProduct, aQuantity) of the class StockCoord, according to the specification and designs given in the implementation model. You are not required to provide the method header or Javadoc comments. (4 marks)

 

 

 

Question 24 (20 marks)

(a) This part of the question is about improving an initial prototype graphical user interface (GUI) design for a desktop computer application to control a ‘Where am I?’ display for the outside of an office door. Read the descriptions below and then answer the questions that follow.

The ‘Where am I?’ display

Figure 11 shows the display outside the office door. The arrow on the display swings to indicate the occupant’s whereabouts. The Unavailable label is fixed but all of the other location labels are programmable. The position of the arrow is driven by a set of sensors whose details you do not need to consider. If a visitor presses the Further details button a message pre-set by the room’s occupant is displayed, for example giving a mobile number for the visitor to text.

The user interface

The initial prototype user interface of the desktop application to control the door display is comprised of two screens, as shown below.

The main screen

The main screen (Where am I?) is intended to allow a user to do the following:

  • enter a set of location labels for the door display
  • associate each location with one of ten sensors which the user indicates by entering numbers (1 to 10) into text fields.
  • provide a message to be displayed when the Further details button on the door display is pressed (this is always the same message irrespective of the location).

From the main screen the user can navigate via a button (Set availability) to the Availability screen.

 

The Availability screen

This screen is intended to allow the user to enter set times of the week when the door display will indicate ‘Unavailable’. This is done using a table. For the purposes of this question all you need to know about tables is that they can be used for entering and displaying information in cells, which are intersections of columns and rows. In this case the columns represent days of the working week and the rows represent times of the working day in hourly intervals.

When the user selects a cell (or group of cells) this is indicated by the cell(s) being highlighted. The user then clicks on the Set unavailable button and these cells become shaded, indicating unavailability.

Clicking on the Back button returns the user to the main screen.

Some user interface design heuristics (introduced in Unit 12) are listed below

Minimise the users’ memory load Be consistent

Allow for undoability and commitment Use simple grouping and ordering

      Prevent errors

 

    1. Use the design heuristic Prevent errors to identify a fault with the design of the main screen and a consequent improvement. Give your answer in the form of a design rationale. (2 marks)
    2. Choose a design heuristic other than Prevent errors from the list given above, for which you can identify a fault with the design of the Availability screen and a consequent improvement. Give your answer in the form of a design rationale. (2 marks)
    3. Explain briefly what kinds of information are usually contained in an initial widget table. (3 marks)

 

 

 

  1. This part of the question is about a Java GUI for a faculty library loan system. Read the description below then answer the questions that follow.

The Borrow Book screen allows the user to initiate the Borrow Book use case. Here is a description of this use case.

Suppose that a user interface designer working on the Borrow Book use case has decided that the user will select from a scrollable list of the (unique) names of all the members of the faculty library. When the user makes this selection a second scrollable list will display the titles of all the available books i.e. all the books the member does not have on loan and for which copies are available to be borrowed. When the Borrow Book screen is first displayed the first name in the list of member names is selected by default and the second list displays the titles of books available to be borrowed by that member.

The librarian selects a member and a book to be borrowed and clicks the Borrow book button. If the selected member already has the maximum number of books on loan, no new loan is recorded and an appropriate message is displayed in the outcome text area. Otherwise the system records the loan of the selected book to the selected member and the details are confirmed by a message in the outcome text area with the following information: the book title, the member’s membership number and name, and the issue and return dates.

This is illustrated by the design sketch in Figure 17.

When this design is implemented the GUI will communicate with the core system implemented in the package librarycore, which includes a coordinating class LibCoord and several other core classes including Loan and Book.

 

Below are extracts from the Javadoc for some methods of the core system classes, some, but not all of which are required for building the Borrow Book screen.

 

Class LibCoord

getMembers

public java.util.Collection getMembers()

Returns a collection of all the members of the library.

Returns:

a collection of all Member objects

getAvailableBooks

public java.util.Collection getAvailableBooks()

Returns the books that have at least one copy not currently being borrowed.

Returns:

a collection of all the Book objects whose copiesAvailable attribute has a value of 1 or more

 

getBooksOnLoan

public java.util.Collection

getBooksOnLoan(Member aMember)

Returns the books on loan to a member.

Parameters:

aMember – a member

Returns:

the Book objects linked to Loan objects linked to aMember.

 

borrowBook

public Loan borrowBook(Book aBook, Member aMember)

Records the borrowing of a book by a member.

If aMember is linked to maximum number of Loan objects then returns null.

Otherwise a new Loan object aLoan is created with date of issue set to the current date, return date set to the current date plus the fixed loan period and:

  1. aLoan is linked to aMember.
  2. aLoan is linked to aBook
  3. aLoan is returned.

This is the coordinating method for Borrow a Book.

Parameters:

aBook – a book being borrowed by a member

aMember – a member borrowing a book

Returns:

the Loan object representing the loan of aBook to aMember

Throws:

IllegalStateException if a copy of aBook is not available to be borrowed.

IllegalArgumentException if aMember already has aBook on loan.

 

Class Book

getTitle

public String getTitle()

Returns the receiver’s title.

Returns:

title

toString

public String toString()

Returns the receiver’s title

Returns:

a string object representing the receiver

 

Class Loan

getIssueDate

public M256Date getIssueDate()

Returns the receiver’s issue date.

Returns:

issueDate

getReturnDate

M256Date getReturnDate()

Returns the receiver’s return date.

Returns:

returnDate

toString

public String toString()

Returns a string representation of the receiver: the book title, the member’s membership number and name and the issue and return dates.

Returns:

a String object representing the receiver

 

Below are some notes on the GUI that you will need to answer parts (i) and (ii).

  • The coordinating object is referenced by the instance variable library of type LibCoord;
  • the first scrollable list (labelled Select the member) is referenced by a variable memberList of type M256JList;
  • the first list is populated with Member objects;
  • the second scrollable list (labelled Select a book to borrow) is referenced by a variable booksToBorrowList of type M256JList;
  • The outcome text area is referenced by a variable outcomeArea of type JTextArea

 

  1. Write code for the body of a method displayAvailableBooks() for the GUI class which handles the selection of an item from the scrollable list of member names. The method should display in the second scrollable list the titles of all the available books. These are all the books in the library except the books the member has on loan, and books with no available copies. The first item in the second scrollable list should be selected by default. You can assume that there will always be at least one book in this list and that when the list is populated with a collection of Book objects, the title corresponding to each Book object will automatically be displayed in the list. (6 marks)
     
  2. Write code for the body of a handler method borrowBook() for the Borrow book button. The method calls on the core system to record the borrowing of a copy of the selected book by the selected member.

If the selected member has already borrowed the maximum number of books no new loan is recorded and a message in the outcome text area states

"The member must return a book before borrowing another one".

Otherwise the loan is recorded and a message is displayed in the outcome text area showing the book title, the member’s membership number and name and the issue and return dates; also the 'Select a book to borrow' list is updated so that it no longer shows the title of the book just borrowed. (7 marks)

 

 

[END OF QUESTION PAPER]

 

Purchase full paper by adding to cart

Last updated: Sep 02, 2021 12:17 PM

Can't find a resource? Get in touch

AcademicianHelp

Your one-stop website for academic resources, tutoring, writing, editing, study abroad application, cv writing & proofreading needs.

Get Quote
TOP