Final 2021
Final 2021
Final Examination
Date: 17/01/2022; Duration: 120 minutes
Online; open book exam
Full name: Nguyễn Văn Sinh Full name: Trần Thanh Tùng
Proctor 1 Proctor 2
Signature Signature
STUDENT INFO
Student name:
Student ID:
a. Explain why the design is violating the Single Responsibility Principle (15 marks)?
b. Redesign (by drawing a new diagram) to make it conform with the Single Responsibility
Principle (10 marks)
3. (30 marks) Dependency Inversion Principle: high-level modules should not depend upon low
level modules. Both should depend upon abstraction.
The following code is an implementation of a login function for MySocialNetwork, but it violates
the Dependency Inversion Principle.
a. Explain why the code violates the Dependency Inversion Principle (15 marks)
b. Rewrite the code to make it conform with the principle (15 marks)
public class My_HCMIU_Email {
public void loginWithStudentID(String username, String password) {
/* ………..*/
}
}
2 /4
HCMC National University Student Name:………...……………………….
International University Student ID:…………………………….
------------
4. (15 marks) Assuming you are developing a Plants vs Zombies game. In the game, there are many plants
and many zombies.
/*…*/ /*…*/
/*…*/ /*…*/
} }
} }
a. Identify and implement/modify classes corresponding to the Subject and the Observer classes in
the pattern (10 marks)
b. Implement a test function to create 2 plants, 2 zombies, any other objects if needed, and then
setup the connections among all components following the Observer pattern (5 marks)
3 /4
HCMC National University Student Name:………...……………………….
International University Student ID:…………………………….
------------
-- The end --
4 /4