ENGR 110: Test Sept 2016

Size: px
Start display at page:

Download "ENGR 110: Test Sept 2016"

Transcription

1 Family Name: Other Names: Student ID: Signature ENGR 110: Test 2 21 Sept 2016 Instructions Time allowed: 50 minutes. Closed Book. Answer all the questions. There are 50 marks in total. Write your answers in the boxes in this test paper and hand in all sheets. If you think some question is unclear, ask for clarification. This test contributes 15% of your final grade You may use paper translation dictionaries, and calculators. You may write notes and working on this paper, but make sure your answers are clear. Questions Marks 1. Implementing Class Diagrams [12] 2. Designing Class Diagrams [13] 3. Use Case Diagrams [12] 4. Activity Diagrams [13] TOTAL:

2 Question 1. Implementing Class Diagrams [12 marks] Consider the following fragment of a class diagram for a program for managing staff and tasks within a medium sized company. The diagram contains three classes with three associations. On the facing page, write code to implement these three classes. You should write field definitions and method headers You do NOT need to write constructors or method bodies. Put a comment against any fields that need to be initialised in the constructor, according to the diagram. BusinessUnit unitname : String responsibility: String budget: Number totalsalaries() : Number addstaffmember(s: StaffMember) unit staff 1 1..* manager 1 StaffMember name : String jobcategory: String salary: Number increasesalary(incr: Number) printclientaccounts() * reports 1 boss Client clients * clientname : String accountnumber: Integer (Question 1 continued on next page) ENGR 110 (Terms Test 2) Page 2 of 10

3 public class BusinessUnit{ private String unitname; private String responsibility ; private double budget; private ArrayList <StaffMember> staff = new ArrayList<StaffMember>(); //initialise private StaffMember manager; // initialise public double totalsalaries (){...} public void addstaffmember(staffmember member){...} } public class StaffMember{ private String name; private String jobcategory; private Number salary; private BusinessUnit unit ; // initialise private StaffMember boss; private ArrayList <StaffMember> reports = new ArrayList<StaffMember>(); private ArrayList <Client> clients = new ArrayList<Client>(); public void increasesalary (double incr ){...} public void printclientaccounts (){...} } public class Client { private String clientname; private int accountnumber; }. ENGR 110 (Terms Test 2) Page 3 of 10

4 Question 2. Designing Class Diagrams [13 marks] Draw a class diagram with at least three classes for a program for helping the shipping dispatcher of a small manufacturing company manage all the shipments out of the factory shipping bay. What comes into the shipping bay are pallets of packages. Each pallet will have a destination to which it should be sent (represented by a String containing the address), and a collection of packets (all of which go to the same destination). Pallets should have actions that return the destination of the pallet compute and returns the total weight of the pallet, check that all packets in the pallet have a destination matching the pallet Each packet contains items of a single type. Each packet is described by a packet identifier (15 digit code) the name of the item, the item code (an 8 character alphanumeric string), a count of the number of items in the package, and the weight of the packet the destination of the packet Pacakages should have actions that return the packet identifier return the destination of the package print out the details of the package The main program should keep track of all the pallets. It will have actions to record a new pallet entering the bay, and check it is valid (all packets go to the same destination). display a list of all the pallets waiting, with their weights and destinations select a pallet to ship out, and remove it from the system. Some pallets may be grouped with up to 5 other pallets, which all need to be shipped together. Make sure your diagram also includes an association to represent groupings of pallets. (Question 2 continued on next page) ENGR 110 (Terms Test 2) Page 4 of 10

5 (Question 2 continued) ShippingManager recordnewpallet() listpallets() shipoutpallet() pallets 0..* Pallet palletid: String destination : String pallet 0..1 totalweight(): Number checkalldestinations(): boolean 0..5 groupedwith Package packages * packageid : String itemname: String itemcode: String itemcount: Integer weight: Number destination: String printdetails() ENGR 110 (Terms Test 2) Page 5 of 10

6 The following description for a vending machine is background for questions 3 and 4. A Vending Machine System A company wants you to produce a program to control its vending machine which can dispense up to 50 kinds of items. The program should allow a customer to purchase a particular item. The user will first select the item and then choose to pay by EFTPOS/credit card. EFTPOS/Credit card payments are handled by a bank authorisation system. If the payment succeeds, then the machine should dispense the specified item. If a payment fails, any card should be returned, and the user should then be given the option to choose another card or to abandon the transaction. The vending machine can be restocked by a technician, who will add items to the racks. A technician should also be able to perform routine maintenance of the vending machine, checking the internal database for when different items were purchased, and recovering any EFTPOS or credit cards that have become lodged in the machine. ENGR 110 (Terms Test 2) Page 6 of 10

7 Question 3. Use Case Diagrams [12 marks] (a) [7 marks] In the box below, draw a use case diagram for the vending machine described above. Make sure to include at least 3 actors and 3 use cases in the system. Purchase secondary <<actor>> Bank AS Customer Restock Maintenance Technician (b) [5 marks] The vending machine company has decided to make its vending machines part of the internet of things. This will require the technician to log in to the company s external service (called Vend IoT ) before being able to either restock the machine or perform routine maintenance. The technician should not have to log in again when switching between use cases. Draw a modified use-case diagram, with an added log in use case, showing how the other use cases for the technician can be extended to allow for the logging in using preconditions and postconditions. Purchase secondary <<actor>> Bank AS Customer Technician Log In Restock Maintenance <<ensures loggedin>> <<requires loggedin>> secondary <<requires loggedin>> secondary secondary <<actor>> Vend IoT ENGR 110 (Terms Test 2) Page 7 of 10

8 Question 4. Activity Diagrams [This question refers to the vending machine system described on page 2.] [13 marks] Convert the following use case body into an activity diagram, making sure to clearly label both error sequences. You may label the boxes using just the bold words in the steps if you wish. Use case: Purchase Item Actors: Customer (primary), Bank Authorisation System (secondary) Actions of actors Actions of system M.1. Customer requests specific item M.2. System checks that the item is in stock M.3. System returns price of item M.4. Machine displays returned price M.5. System asks for card type of selected item M.6. Customer selects card type M.7. System requests card M.8. Customer supplies card M.9. System requests approval for transaction. M.10. Bank AS reports transaction approved. M.11. System ejects card M.12. Item dispensed Alternative scenario A1: Transaction failed. The A1 scenario starts after step M.9 of the main success scenario Actions of actors Actions of system A.1. Bank AS reports that transaction failed A.2. System returns card A.3. System asks if alternative card option is to be attempted A.4. Customer choses to attempt alternative A.5. Go to M.5 card Error scenario E1: The selected item is out of stock The E1 scenario starts after step M.2 of the main success scenario Actions of actors Actions of system E.1. System finds requested item is out of stock E.2. System reports that item is out of stock. Use Case fails. Error scenario E2: Transaction abandoned The E2 scenario starts after step A.3 of the alternative scenario Actions of actors Actions of system E.1. Customer chooses not to attempt alternative card option. been abandoned. Use Case E.2. System reports that transaction has fails. (Question 4 continued on next page) ENGR 110 (Terms Test 2) Page 8 of 10

9 (Question 4 continued) * * * * * * * * * * * * * * * ENGR 110 (Terms Test 2) Page 9 of 10

10 SPARE PAGE FOR EXTRA ANSWERS Cross out rough working that you do not want marked. Specify the question number for work that you do want marked. ENGR 110 (Terms Test 2) Page 10 of 10