Professional Documents
Culture Documents
SWE3053 Q July2022 - FinalExam
SWE3053 Q July2022 - FinalExam
INSTRUCTIONS TO CANDIDATES
This is an open-book online exam. It is your responsibility to ensure that you only depend on the
materials taught in the classes and other references you may find helpful. Consulting external
people or other colleagues is not allowed.
Question 1 (15 marks)
In mobile e-hailing applications such as Grab, users use the system often to book several types
of transportation means (e.g. budget cars). Users can check the fare before confirming their
booking. Once a booking is confirmed, the passenger can see the driver name and the car’s
real-time location on the map. Also, they can pay the fare using several means (e.g. online
payment).
Assume you are a maintenance engineer in a team that is responsible for maintaining the
application in the following scenario:
The scenario: “An issue has been discovered in the system makes it possible for users
to access the system in unwanted ways (e.g. modify the fares). As a maintenance
engineer, you are asked to maintain the system as fast as possible so that the users cannot
change the decided fares. Given that this issue has been resolved, several complaints
have been later sent to the maintenance team that the actual driver location is not shown
instantly to the passenger so that there is some latency. As a maintenance engineer, you
are also required to resolve this problem.”
a) For every required maintenance activity in the scenario and based on the decision tree-
based criteria in Figure 1:
i. Identify the cluster to be maintained via answering the related questions. [4 marks]
ii. Identify evidence maintenance type via answering the related questions. [4 marks]
-Figure 1-
b) Propose another scenario in which a change request is sent by one stakeholder to address
an issue in the system and accordingly a maintenance activity is required. Decide what
maintenance type is required based on the decision tree-based criteria in Figure 1 by
answering the related questions with justification. [4 marks]
According to SPE taxonomy, select the type of the tackled e-hailing application in the
above-mentioned scenario. Justify your answer in detail. [3 marks]
Question 2 (5 marks)
1. import java.util.ArrayList;
2. import java.util.Scanner;
3. public class MovieManagementSystem {
4. public static void main(String[] args) {
5. ArrayList<String> MovieTitles = new ArrayList<String>();
6. String newMovietitle;
7. int MCount = 0; // the number of movies in the system
8. int AcMCount = 0 ; // number of action movies in the system
9. int AdMoviesCount = 0 ; // number of adventure movies in the system
10. double TotalRating=0; // The total sum of all ratings of all movies
11. double TotalAcMRating=0;// The total sum of all ratings of action movies
12. double TotalAdMRating=0;// The total sum of all ratings of adventure movies
13. double AverageRating=0;// The average rating of all movies
14. double AverageAcMRating = 0; // The average rating of action movies
15. double AverageAdMRating = 0; // The average rating of adventure movies
16. Scanner input = new Scanner(System.in);
17. System.out.print("Enter a new movie title: ");
18. newMovietitle = input.next();
19. while (!(newMovietitle.equals("end"))) {
20. MovieTitles.add(newMovietitle);
21. MCount = MCount + 1;
22. System.out.print("Enter the movie rating: ");
23. double mrating= input.nextDouble();
24. System.out.print("What is the movie type: (Action/Adventure)");
25. String mtype= input.next();
26. if (mtype.equalsIgnoreCase("Action"))
27. {
28. AcMCount += 1 ;
29. TotalAcMRating += mrating;
30. }
31. if (mtype.equalsIgnoreCase("Adventure"))
32. {
33. AdMoviesCount += 1 ;
34. TotalAdMRating += mrating;
35. }
36. TotalRating += mrating ;
Question 4 (9 marks)
-Figure 3-
Consider that following java code, shown in Figure4, for a learning management system
requires some refactoring effort to improve its quality.
1. import java.util.Scanner;
2. public class LearningManagementSystem {
3. public static void main(String[] args) {
4. String studentName;
5. System.out.println("Enter a student name to be enrolled");
6. Scanner input = new Scanner(System.in);
7. studentName = input.next();
8. while (!(studentName.equals("end"))) {
9. Student stdObj = new Student(studentName);
10. System.out.print("Enter a student name to be enrolled");
11. studentName = input.next();
12. }
13. System.out.println("The Enrolled students are ");
14. for(Object studentObj: Student.getInstances()){
15. System.out.println("The student "+((Student)studentObj).studentName+"
"+ "is enrolled");
16. }
17. }
18. }
1. import java.util.ArrayList;
2. public class Student {
3. public String studentName;
4. private static ArrayList instances = new ArrayList();
5. public Student(String name){
6. this.studentName = name;
7. instances.add(this);
8. }
9. public static ArrayList getInstances() {
10. return instances;
11. }
12. }
-Figure 4-
Propose two refactorings on the code as follows. For every required refactoring, show the
code to be added and modified and explain the benefit of doing the refactoring.
a) Employ the extract method refactoring to extract a method for listing the enrolled
students and to use it in the code; (the extracted method shall perform the same
functionality performed by the lines of code 13-16 in the class
LearningManagementSystem). [3 marks]
b) Employ the concept of Encapsulate Field to encapsulate studentName. [3 marks]
~ END OF PAPER ~