Mid-year Examinations, 2019
SENG201-19S1 (C)
Family Name First Name Student Number Venue
Seat Number
Copyright By PowCoder代写 加微信 powcoder
_____________________ _____________________ |__|__|__|__|__|__|__|__| ____________________ ________
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.
For Examiner Use Only
Question Mark
Page 1 of 17
Mid-year Examinations, 2019 SENG201-19S1 (C)
Questions Start on Page 3
Page 2 of 17
Mid-year Examinations, 2019 SENG201-19S1 (C)
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. [2marks]
Compiles: Yes/no (circle answer)
Output (if statement compiles): _________________________________________________ Reason if statement does not compile: ____________________________________________
b. [2marks]
while (true || 5/0 > 1) {
System.out.println(“I’m not sure of this one!”);
Integer try = 0;
double rand = Math.random();
if (rand * 10 < 5) {
System.out.println("You won!"); } else {
System.out.println("Try again.");
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. [2marks]
Compiles: Yes/no (circle answer)
Output (if statement compiles): _________________________________________________ Reason if statement does not compile: ____________________________________________
char nine = '\uffff';
char three = '\uffff'; System.out.println(nine/three);
Page 3 of 17
Student ID ____________________ Student Number |__|__|__|__|__|__|__|__|
Mid-year Examinations, 2019 SENG201-19S1 (C)
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
Your answer:
In line 11, class ______________________ implements interface ______________________.
In line 12, interface ______________________ is being implemented by class ______________________.
import java.util.HashSet; import java.util.List; import java.util.Set;
public class SomeStuff {
public static void main(String[] args) {
List
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());
import java.util.ArrayList;
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?
Page 4 of 17
Student ID ____________________ Student Number |__|__|__|__|__|__|__|__|
Mid-year Examinations, 2019 SENG201-19S1 (C)
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.
Your answer:
Allows positional access
Allows duplicates
Order of elements remains the same over time
Allow null values
listA setB
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: ____________________________________
Page 5 of 17
Student ID ____________________ Student Number |__|__|__|__|__|__|__|__|
Mid-year Examinations, 2019 SENG201-19S1 (C)
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.
Page 6 of 17
Student ID ____________________ Student Number |__|__|__|__|__|__|__|__|
Mid-year Examinations, 2019 SENG201-19S1 (C)
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. [6marks]Proposeandexplaintwodesignpatternstocorrecttheviolationsidentifiedinquestion 3.a.
Your answer:
Page 7 of 17
Student ID ____________________ Student Number |__|__|__|__|__|__|__|__|
Mid-year Examinations, 2019 SENG201-19S1 (C)
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:
Page 8 of 17
Student ID ____________________ Student Number |__|__|__|__|__|__|__|__|
Mid-year Examinations, 2019 SENG201-19S1 (C)
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:
Page 9 of 17
Student ID ____________________ Student Number |__|__|__|__|__|__|__|__|
Mid-year Examinations, 2019 SENG201-19S1 (C)
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:
Page 10 of 17
Student ID ____________________ Student Number |__|__|__|__|__|__|__|__|
Mid-year Examinations, 2019 SENG201-19S1 (C)
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:
Your answer:
GIVEN: status = OFF WHEN: power() THEN: status = ON
//preconditions, the initial state //what caused the transition //post-conditions, the expected state
Page 11 of 17
Student ID ____________________ Student Number |__|__|__|__|__|__|__|__|
Mid-year Examinations, 2019 SENG201-19S1 (C)
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. [2marks]Explaininyourownwordswhatthe3-tierarchitecturepatternis.Inyouranswer,you should provide two different characteristics of the pattern explained as a bullet point using one or two sentences.
Your answer:
Page 12 of 17
Student ID ____________________ Student Number |__|__|__|__|__|__|__|__|
Mid-year Examinations, 2019 SENG201-19S1 (C)
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:
Page 13 of 17
Student ID ____________________ Student Number |__|__|__|__|__|__|__|__|
Mid-year Examinations, 2019 SENG201-19S1 (C)
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:
Page 14 of 17
Student ID ____________________ Student Number |__|__|__|__|__|__|__|__|
Mid-year Examinations, 2019 SENG201-19S1 (C)
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:
Page 15 of 17
Student ID ____________________ Student Number |__|__|__|__|__|__|__|__|
Mid-year Examinations, 2019 SENG201-19S1 (C)
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 ___:
Page 16 of 17
Student ID ____________________ Student Number |__|__|__|__|__|__|__|__|
Mid-year Examinations, 2019 SENG201-19S1 (C)
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
Page 17 of 17
Student ID ____________________ Student Number |__|__|__|__|__|__|__|__|
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com