辅导案例-SENG201
Mid-year Examinations, 2019 SENG201-19S1 (C)
Page 1 of 17


No electronic/communication devices are permitted.
No exam materials may be removed from the exam room.

Computer Science and Software Engineering
EXAMINATION
Mid-year Examinations, 2019
SENG201-19S1 (C) Software Engineering I

Examination Duration: 120 minutes
Exam Conditions:
Open Book exam: Students may bring in any written or printed materials.
Any scientific/graphics/basic calculator is permitted.
Materials Permitted in the Exam Venue:
Open Book exam: Students may bring in any written or printed materials.
Materials to be Supplied to Students:
1 x Write-on question paper/answer book
Instructions to Students:
Mark or write in the spaces allocated to each answer. Do not write close to the margins,
as the answer books will be scanned, and writing very close to the margin may not be
picked up. If you require extra room there are space at the end of this booklet.
You should clearly indicate in the appropriate space that the answer is
continued/provided elsewhere.
Family Name _____________________
First Name _____________________
Student Number |__|__|__|__|__|__|__|__|
Venue ____________________
Seat Number ________
For Examiner Use Only
Question Mark





















Total ________
Mid-year Examinations, 2019 SENG201-19S1 (C)
Page 2 of 17






Questions Start on Page 3

Mid-year Examinations, 2019 SENG201-19S1 (C)
Page 3 of 17
1. [8 marks for whole question] Do the following Java code fragments compile? If they do not compile, explain
why a fragment does not compile. If they do compile, what is their output? Note that we expect the exact
output (e.g., if the output is a string then the printed string needs to be exact, including punctuation).
Assume that fragments are taken from within a method of a Java class. Also, you can assume that all
relevant classes are imported. (a) to (d) are not related (i.e., a variable in one question is independent
from the same variable in another question).

a. [2 marks]
while (true || 5/0 > 1) {
System.out.println("I'm not sure of this one!");
break;
}
Compiles: Yes/no (circle answer)
Output (if statement compiles): _________________________________________________
Reason if statement does not compile: ____________________________________________

b. [2 marks]
Integer try = 0;
do {
double rand = Math.random();
if (rand * 10 < 5) {
System.out.println("You won!");
} else {
System.out.println("Try again.");
}
try++;
}
while (try < 2);

Compiles: Yes/no (circle answer)
Output (if statement compiles): _________________________________________________
Reason if statement does not compile: ____________________________________________

c. [2 marks]
String s1 = "true";
String s2 = "TRUE";
Boolean s3 = s2 == s1;
System.out.println(s2 && s3);

Compiles: Yes/no (circle answer)
Output (if statement compiles): _________________________________________________
Reason if statement does not compile: ____________________________________________

d. [2 marks]
char nine = '\uffff';
char three = '\uffff';
System.out.println(nine/three);

Compiles: Yes/no (circle answer)
Output (if statement compiles): _________________________________________________
Reason if statement does not compile: ____________________________________________

Student ID ____________________
Student Number |__|__|__|__|__|__|__|__|
Mid-year Examinations, 2019 SENG201-19S1 (C)
Page 4 of 17
2. [16 marks for whole question] Study the following program (line numbers are provided for your
convenience; they are not part of the program). You can assume that class Flight is implemented in file
Flight.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class SomeStuff {

public static void main(String[] args) {

List listA = new ArrayList();
List listB = new ArrayList();
Set setA = new HashSet();
Set setB = new HashSet();

listA.add(new Flight("Mexicana", "MX145", 98));
listA.add(new Flight("Lufthansa", "LH492", 86));
listA.add(new Flight("Aeroflot", "SU001", 66));
listA.add(new Flight("Aeromexico", "AM341", 73));
listA.add(new Flight("Air New Zealand", "NZ210", 98));

listB.add(5784);
listB.add(5487);
listB.add(null);
listB.add(7854);
listB.add(8457);
listB.add(4587);
listB.add(5487);
listB.add(7845);
listB.remove(1);
listB.remove(1);

setA.addAll(listB);
setA.remove(5);

setB.addAll(listA);
setB.add(new Flight("Jetstar", "JQ225", 60));

System.out.println("List A: " + listA);
System.out.println("List A size is: " + listA.size());
System.out.println("List B: " + listB);
System.out.println("Does List B contain null values? " + listB.contains(null));
System.out.println("Set A: " + setA);
System.out.println("Does Set A contain value 5487? " + setA.contains(5487));
System.out.println("Set B: " + setB);
System.out.println("Set B size is: " + setB.size());
}
}

a. [4 marks] State clearly for lines 11 and 12 which interface is being used and which class
implements which interface in lines 11 and 12?

Your answer:

In line 11, class ______________________ implements interface ______________________.

In line 12, interface ______________________ is being implemented by class ______________________.

Student ID ____________________
Student Number |__|__|__|__|__|__|__|__|
Mid-year Examinations, 2019 SENG201-19S1 (C)
Page 5 of 17
b. [8 marks] Summarize the differences between the collections defined in lines 10 and 13 by
indicating Yes or No to the questions provided in the table below.


















c. [4 marks] State what the output obtained from lines 39, 41, 43 and 45 is.

Your answer:


Line 39: ____________________________________


Line 41: ____________________________________


Line 43: ____________________________________


Line 45: ____________________________________














Your answer:
listA setB
Allows positional access
Allows duplicates
Order of elements remains the same
over time

Allow null values

Student ID ____________________
Student Number |__|__|__|__|__|__|__|__|
Mid-year Examinations, 2019 SENG201-19S1 (C)
Page 6 of 17
3. [25 marks for whole question] Figure 1 shows a class diagram for a “Space Explorer” game, similar to the
game you developed for this year’s SENG201 project. You can assume that all classes in the diagram have
properties and methods necessary for the app to function but were excluded from Figure 1 for simplicity.


Figure 1. UML class diagram for Space Explorer game (omitting properties and methods)

Answer the following questions, and state all of the assumptions you make for your answers.




















Student ID ____________________
Student Number |__|__|__|__|__|__|__|__|
Mid-year Examinations, 2019 SENG201-19S1 (C)
Page 7 of 17
a. [8 marks] The class design shown in Figure 1 violates several good software engineering design
principles. Identify and explain two design flaws that are being violated in the class diagram and
any problem(s) each flaw may cause. The design flaws must be clearly identified and explained in
two or three sentences each, i.e., it is not sufficient to state “The system design is rigid”. The
explanation must also point out which elements of the diagram contribute to the design flaw
and the problem the flaw causes.

Your answer:




















b. [6 marks] Propose and explain two design patterns to correct the violations identified in question
3.a.

Your answer:




















Student ID ____________________
Student Number |__|__|__|__|__|__|__|__|
Mid-year Examinations, 2019 SENG201-19S1 (C)
Page 8 of 17
c. [11 marks] Using the two design patterns identified in (b), redraw the redesigned UML class
diagram. Your redesigned UML class diagram should include at least three different types of
relationships.

Your answer:














































Student ID ____________________
Student Number |__|__|__|__|__|__|__|__|
Mid-year Examinations, 2019 SENG201-19S1 (C)
Page 9 of 17
4. [28 marks for whole question] You are hired by a local software start-up to help develop a new app that is
an app of apps - a super app - that acts like your own efficient travel executive assistant.
a. [14 marks] Sketch a UML use case diagram to discuss the features of this new app with your
colleagues. The app should:
 Allow users to create their own profile; search for travel buddies with similar interests;
plan their trips; post their adventures and be able to attach images, media, and text
(like a mini blog); display their trips on a map; and, share them with others.
 Eventually, allow property owners to post accommodation offers and event organizers
to list their events.
 In this way, users will have a wide variety of accommodation and leisure alternatives
and they will be able to book and pay for the services (accommodation and events).
Your use case diagram should include at least four actors, at least four use cases, and must
follow UML use case diagrams notation.
Your answer:





































Student ID ____________________
Student Number |__|__|__|__|__|__|__|__|
Mid-year Examinations, 2019 SENG201-19S1 (C)
Page 10 of 17
b. [6 marks] Draw a state transition diagram for the life cycle of a hotel reservation. The diagram
should include at least three states. State all assumptions you make.
Your answer:
















































Student ID ____________________
Student Number |__|__|__|__|__|__|__|__|
Mid-year Examinations, 2019 SENG201-19S1 (C)
Page 11 of 17
c. [8 marks] Draft four unit test cases derived from the question 4.b diagram. Include pre and post-
conditions of the test cases. Note that your test cases do not have to be fully formed JUnit tests.
Hint: An expected test case might look like this:
GIVEN: status = OFF //preconditions, the initial state
WHEN: power() //what caused the transition
THEN: status = ON //post-conditions, the expected state

Your answer:











































Student ID ____________________
Student Number |__|__|__|__|__|__|__|__|
Mid-year Examinations, 2019 SENG201-19S1 (C)
Page 12 of 17
5. [14 marks for whole question] Figure 2 shows a sequence diagram for a travel planner app. Assume that
this app follows a 3-tier architecture and all classes in the diagram have properties and methods
necessary for the app to function but were excluded from Figure 2 for simplicity.


Figure 2. UML sequence diagram for a travel planner app
Answer the following questions, and state all of the assumptions you make for your answers.

a. [2 marks] Explain in your own words what the 3-tier architecture pattern is. In your answer, you
should provide two different characteristics of the pattern explained as a bullet point using one
or two sentences.

Your answer:

















Student ID ____________________
Student Number |__|__|__|__|__|__|__|__|
Mid-year Examinations, 2019 SENG201-19S1 (C)
Page 13 of 17
b. [6 marks] Based on the sequence diagram in Figure 2, create a new version by:
 Correcting errors in the diagram, if any.
 Adding steps to it. The steps should represent an alt or a loop flow (choose only one).
State all assumptions you make.

Your answer:













































Student ID ____________________
Student Number |__|__|__|__|__|__|__|__|
Mid-year Examinations, 2019 SENG201-19S1 (C)
Page 14 of 17
c. [6 marks] Create a UML package diagram that represents the 3-tier architecture derived from the
question 5.b diagram. The diagram should include the content of each package.

Your answer:















































Student ID ____________________
Student Number |__|__|__|__|__|__|__|__|
Mid-year Examinations, 2019 SENG201-19S1 (C)
Page 15 of 17
6. [9 marks for whole question] List and explain in bullet points three reasons for why a risk assessment early
in a software project (and throughout a project) can potentially reduce rework and increase the success
rate of a software project. Include examples of risks to justify your reasons (one example per bullet).

Your answer:
Reason 1:














Reason 2:















Reason 3:














Student ID ____________________
Student Number |__|__|__|__|__|__|__|__|
Mid-year Examinations, 2019 SENG201-19S1 (C)
Page 16 of 17
You can use this extra page for answering any exam questions that need extra space. State clearly which
question you are answering (print the number of the question).
Your answer to question ___:
















































Student ID ____________________
Student Number |__|__|__|__|__|__|__|__|
Mid-year Examinations, 2019 SENG201-19S1 (C)
Page 17 of 17
You can use this extra page for answering any exam questions that need extra space. State clearly which
question you are answering (print the number of the question).
Your answer to question ___:













































End of Examination
Student ID ____________________
Student Number |__|__|__|__|__|__|__|__|
51作业君 51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: IT_51zuoyejun