1651 - ASM2 - Advanced Programming, Study Guides, Projects, Research of Information Technology

this is assignment 2 of Advanced Programming (1651).

Typology: Study Guides, Projects, Research

2021/2022

Uploaded on 10/27/2022

thanh-phong-1
thanh-phong-1 🇻🇳

4.6

(7)

2 documents

1 / 28

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
ASSIGNMENT 2 FRONT SHEET
Qualification
BTEC Level 5 HND Diploma in Computing
Unit number and title
Unit 20: Advanced Programming
Submission date
01/09/2022
Date Received 1st submission
01/09/2022
Re-submission Date
Date Received 2nd submission
Student Name
Do Thanh Phong
Student ID
GCH190859
Class
GCH0902
Assessor name
Doan Trung Tung
Student declaration
I certify that the assignment submission is entirely my own work and I fully understand the consequences of plagiarism. I understand that
making a false declaration is a form of malpractice.
Student’s signature
Grading grid
P3
P4
M3
M4
D3
D4
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c

Partial preview of the text

Download 1651 - ASM2 - Advanced Programming and more Study Guides, Projects, Research Information Technology in PDF only on Docsity!

ASSIGNMENT 2 FRONT SHEET

Qualification BTEC Level 5 HND Diploma in Computing Unit number and title Unit 20: Advanced Programming Submission date 01/09/2022 Date Received 1st submission 01/09/ Re-submission Date Date Received 2nd submission Student Name Do Thanh Phong Student ID GCH Class GCH 0902 Assessor name Doan Trung Tung Student declaration I certify that the assignment submission is entirely my own work and I fully understand the consequences of plagiarism. I understand that making a false declaration is a form of malpractice. Student’s signature Grading grid P3 P4 M3 M4 D3 D

 Summative Feedback:  Resubmission Feedback:

Grade: Assessor Signature: Date: Lecturer Signature:

Table Of Figure

Figure 1: Class diagram.................................................................................................................................................. 5 Figure 2: Ward.cs........................................................................................................................................................... 9 Figure 3: MyObserver.cs ............................................................................................................................................. 10 Figure 4: Analyst.cs ...................................................................................................................................................... 10 Figure 5:Fanpage.cs ..................................................................................................................................................... 11 Figure 6: ProvincialChairman.cs .................................................................................................................................. 12 Figure 7: Subject.cs...................................................................................................................................................... 16 Figure 8: Menu.cs ........................................................................................................................................................ 17 Figure 9: MenuProgram.cs .......................................................................................................................................... 18 Figure 10: ManagerWard.cs ........................................................................................................................................ 19 Figure 11: ManagerObserver.cs .................................................................................................................................. 20

I. Introduce.

In the first report, my team and I gave the general concepts of OOP (object-oriented programming) and a description of the payroll management program using use case diagrams and class diagrams. In the next part, our team learned the concept of design patterns and selected a specific design pattern to find scenarios and build class diagrams. In that I selected the observer pattern it belongs to the behavior pattern group, then I selected the scenario of updating covid information in a city and gave a class diagram for that scenario. In this report, I will implement that scenario, and give pros and cons, compare it with other design parts, and why it fits the scenario.

II. Scenario analysis.

a) Scenario.

In the context of the covid-19 pandemic, which is currently the most concerned topic, every change needs to be updated regularly and quickly for everyone. Since it is very important to update information quickly, the Ministry of Health will put each ward's epidemic information on the cloud so that the registrants will be automatically updated for any changes. For example, the government can quickly make announcements that are appropriate to the actual situation, fan pages can give information to viewers, or can calculate the rate for analysis. In order to update information and give instructions or warnings quickly, the provincial president needs to closely monitor the changing data of each direction in the province, fan pages need to provide data on the number of infections and deaths, now update of each ward, in addition, the ratios should also be given. For ordinary people, when registering to receive notifications from the Ministry of Health, they will receive information such as continuous updates of new cases, total current cases in the country update time, and advice. Also. the system can remove or add other observers at runtime.

b) Diagram.

  • Diagram. Figure 1 : Class diagram.

ProvincialChairman - This class inherits the MyObserver class and overrides the Update() method.

  • The function of this layer is to record the state (green zone, red zone, orange zone) of a ward-based on the number of infections per total population in a direction, and apply the state of the city (distance, quarantine, etc.) blockade, normal operation) Fanpage - This class inherits the MyObserver class and overrides the Update() method.
  • The function of this class is to print out the covid epidemic information of the ward, the date and time have changed, the status in the wards is at what level. Analyst - This class inherits the MyObserver class and overrides the Update() method.
  • The function of this class is to calculate the morbidity and mortality rates of all measures.

III. Implementation.

a) Code.

• Ward.cs

  • Declare properties and properties for class Ward.
  • Here I have to validate attribute name and attribute numOfPeople when user input via set function.
  • Create a constructor with parameters for the Ward class so that outsiders can instantiate instances of the Ward class.
  • Show(): method to print information of Class Ward.
  • Edit(): The first is to print out the information of the found ward, then print it, call the ShowMenu() method to print the value to be changed, and then call the DoTask() method to make that change and assign the return value of DoTask()a for choice. All this processing is placed in the while(true) loop if choice equal 0 will stop the loop.
  • Menu():To print the value to be changed.
  • MyObserver.cs Figure 3 : MyObserver.cs - Have a Subject - Abstract class includes two attributes, name and, subject, with an access level of protected. - Constructor that assigns values to two attributes. - Abstract method Update() - Overridden method ToString() to provide externally Observer's name.
  • Analyst.cs Figure 4 : Analyst.cs - Have a Subject - Inherit class MyObserver through ":". - Constructors have parameters that indirectly assign values to attributes via ": base(...)". - Override the Update() method, in the Update() method calculate the total population, number of cases, number of deaths of all wards, then calculate the rate, rateDie and call the Show(rate, rateDie) function to Displays morbidity and mortality rates. - Show(): To Displays morbidity and mortality rates
  • Fanpage.cs
    • Have a Subject
    • Inherit class MyObserver through ":"
    • Constructors have parameters that indirectly assign values to attributes via ": base(...)".
    • Override the Update() method, in the Update() method calculate the total number of cases, the number of deaths of all wards, then call the Header(sum,die), Main(), Footer() functions to display the message board.
    • Header():Print the first part information such as subject name, total number of cases, total number of deaths of subject. Figure 5 :Fanpage.cs
  • Main(): Print information of each ward.
  • Footer():Print the subject's update time.
  • Subject.cs
    • Have a two sets of Ward and MyObserver.
    • Two contructers with and without parameters in each constructor initialize the List so that no Null exception error occurs.
    • AttackMyObserver() and DetachMyObserver() to add and remove elements of observers.
  • NotifyMyObsever() iterates over all elements and implements the Update() method for each element.
  • WardInfoChanged(): Call the NotifyMyObserver() method Add Ward (): Enter the new section information for wards when add to be a success call WardInfoChanged () method to notify for MyObsever object in obsevers.

Figure 7 : Subject.cs

  • GetAmout(string request): Prints the input message and retrieves the value entered by the user.
  • ShowAll(): Print all information of Ward object in wards.
  • EditIFoWard(): same DeleteWard() but it edit information.
  • Menu.cs Figure 8 : Menu.cs This is an abstract class with two abstract methods containing four methods in which two abstract methods are PrintMenu() and DoTask(), both these methods and the GetChoice() method have protected access level, and the Run() method has public access. - Run(): Provide a method to run menu for users - GetChoice(): return the value entered by the user.
  • ManagerWard.cs Figure 10 : ManagerWard.cs - Have a Subject - Inherit class Menu through ":" - The constructor to assigns a value to the subject. - Override DoTask(), PrintMenu()
  • ManagerObserver.cs
    • Have a Subject
    • Inherit class Menu through ":"
    • The constructor to assigns a value to the subject.
    • Override DoTask(), PrintMenu() Figure 11 : ManagerObserver.cs