ExamBank Scot · AH Computing Science question bank · All AH Computing Science questions

AH Computing Science 2019 Question 4 (CfE)

15 marks · UML use case diagrams

With reference to the information above, draw a use case diagram to represent the requirements of the online booking system. The layout of the coach’s seats is shown below. Driver 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 Toilet 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 Booking management software is being developed to store seats sold for each journey. The software will store the following information for each seat. Details stored Sample data customer’s name John contact phone number 01313321249 the cost of the seat 45.00 whether or not the seat has been sold TRUE Using a programming language of your choice, define a record structure to store a seat’s information. Using a programming language of your choice, declare a 2-D array called seatingPlan to store each seat from the coach layout on page 8. Each seat is assigned the initial values “Empty”, “Null”, 0.0 and false. Note that seats 23, 24, 27 and 28 have been replaced by a toilet so they should be declared with the initial values “Toilet”, “Null”, 0.0 and true. Use pseudocode to design a sub-routine to initialise the variable seatingPlan with the appropriate values. When checking seat availability, the cost of the first available seat is displayed before the user chooses whether to book the seat. The seats are allocated sequentially (from seat 1 on row 1) on a first-come, first-served basis, with a total of 48 seats available. Seat prices are shown in the table below. Seats 1 to 20 in rows 1 to 5 Seats 21 to 44 in rows 6 to 11 Seats 45 to 52 in rows 12 and 13 £22.50 £45.00 £75.00 Using pseudocode, or a programming language of your choice, write a sub-routine to • check for the first available seat in the seatingPlan array • display ‘No Availability’ or the cost of first available seat, as appropriate • ask the user if they wish to book the seat • add the appropriate information to this seat record, if the user chooses to proceed. Note any assumptions you make. The company considers incorporating concurrent programming techniques into its booking management software. Describe one problem that could arise in this situation from the use of multiple threads. The company wants to make the booking management software available as a mobile app. Name and describe the type of maintenance that would be required. A coach company runs a daily journey from Edinburgh to London. Users of the company website can check seat availability, book a seat and make payments online. Registered users can login to edit or cancel a booking.

Marking scheme

1 mark for (at least) 2 correct actors 1 mark for 6 use cases with interactions 1 mark for appropriate use made of inheritance, extends or includes (between actors or use cases) OR 1 mark for appropriate extra actor RECORD seatInfo {STRING name, STRING contactNumber, REAL cost, BOOLEAN sold} 1 mark for record structure DECLARE seatingPlan AS ARRAY OF ARRAY OF seatInfo INITIALLY [[]] <with 13 rows and 4 columns> 1 mark for correct 2D array of seatInfo records Note: dimensions [12][3] are also acceptable 1. loop for rows 0 TO 12 2. loop for columns 0 TO 3 3. if (column = 2 or column = 3) AND (row = 5 or row = 6) then 4. set seatingPlan[row][column] to seatInfo ("Toilet", "Null", 0.00, TRUE) 5. else 6. set seatingPlan[row][column] to seatInfo ("Empty", "Null", 0.00, FALSE) 7. end if 8. end column loop 9. end row loop 1 mark for correct loops to process the 2D array 1 mark for correctly initialising seats 1 mark for correctly initialising toilets Note: initialisation should make use of record structure that forms each element of the 2D array SET freeSeatFound TO FALSE SET column TO 0 SET row TO 0 SET ticketPrice TO 0.00 // Check if seat available REPEAT UNTIL freeSeatFound = TRUE OR (column = 4 AND row = 13) IF seatingPlan[row] [column].sold = FALSE THEN SET freeSeatFound TO TRUE SET rowFound TO row SET columnFound TO column END IF IF column < 3 THEN SET column TO column + 1 ELSE SET column TO 0 SET row TO row + 1 END IF END REPEAT // Offer seat to customer IF freeSeatFound = TRUE THEN IF rowFound >=0 AND rowFound <=4 THEN SET ticketPrice TO 22.50 ELSE IF rowFound >=11 AND rowFound <=12 THEN SET ticketPrice TO 75.00 ELSE SET ticketPrice TO 45.00 END IF SEND "The ticket price is " & ticketPrice & " proceed with order?" TO DISPLAY RECEIVE answer FROM KEYBOARD IF answer = <YES> THEN <store user data and price to record and update sold field of the record> END IF ELSE SEND "No seats left" TO DISPLAY END IF 1 mark for checking next available seat 1 mark for correct use of 2D array 1 mark calculating correct cost 1 mark for • asking user to proceed • updating array with correct details 1 mark for • correctly displaying not available • displaying cost of first available seat Note: accept assumption stating that prices have already been assigned rather than code/ pseudocode showing the assignment of prices • One thread checks for availability but before it allocates the seat, another thread does the same – which results in a double-booking • Even if only 1 seat was available, 2 people would believe they have a seat, however the system would have overwritten the final seat allocation • Potential for over-booking the coach 1 mark for any bullet Adaptive maintenance. Booking management software will need to be adapted to be compatible with platform/device 1 mark for adaptive with description

Previous question: AH Computing Science 2019 Question 3 (CfE)

Next question: AH Computing Science 2022 Question 1