1651 assignment 2 (pass) 1651 assignment 2 (pass) 1651 assignment 2 (pass) 1651 assignment 2 (pass) 1651 assignment 2 (pass) 1651 assignment 2 (pass) 1651 assignment 2 (pass) 1651 assignment 2 (pass) 1651 assignment 2 (pass) 1651 assignment 2 (pass) 1651 assignment 2 (pass) 1651 assignment 2 (pass) 1651 assignment 2 (pass) 1651 assignment 2 (pass) 1651 assignment 2 (pass) 1651 assignment 2 (pass) 1651 assignment 2 (pass) 1651 assignment 2 (pass) 1651 assignment 2 (pass) FPT Greenwich
FRONT SHEET
Assessor name: LE NGOC THANH
Learner’s name: Đào Vĩnh Khang
Qualification BTEC Level 5 HND Diploma in Computing
Unit number and title Unit 20: Advanced Programming
Submission date 14-02-2022 Date Received 1st submission 14-02-2022
Re-submission Date Date Received 2nd submission
Student Name DAO VINH KHANG Student ID GCS200222
Class GCS0905B Assessor name LE NGOC THANH
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
BRIEF
Introduction
In this assignment, I will develop an application based on the UML class diagram created in assignment 1, while also exploring various design patterns, including creative, structural, and behavioral patterns, along with relevant examples.
My report includes two parts: ÷ Build an application derived from UML class diagram ÷ Design patterns
II Build an application derived from UML class diagrams
1 Characteristics of the object-orientated paradigm
The Object class sits at the pinnacle of the type hierarchy, with Type 1 and Type 2 serving as reference types Class 1 directly inherits from the Object class, while Class 2 inherits from Class 1 Additionally, Struct1 is a value type that implicitly derives from the Object class via the System.ValueType type.
The Shape class is designed with essential fields, properties, and methods, utilizing public and private access modifiers to implement abstraction by selectively hiding and exposing certain functionalities according to specific requirements.
The public modifier enables access to fields, properties, and methods from outside the class, while the private modifier restricts access to these elements, ensuring they remain hidden from external use.
- By creating an instance of the Shape class, we can access defined fields, properties, and methods
In the program, the Inheritance class encapsulates its variables as private, ensuring data protection To access these private variables, we utilize the public Name and Age accessors, which include get and set methods for retrieving and modifying the values of the private fields This design allows other classes to interact with the private data effectively.
In this article, we demonstrate how to use the Labrador class to access the Name field and the display() method, showcasing the concept of inheritance The derived class inherits all fields and methods from the base class, allowing us to access the Name field within the methods of the Inheritance class.
In object-oriented programming, a base class named Animal can be created, featuring a method called animalSound() This base class can have derived classes such as Pigs, Cats, Dogs, and Birds, each implementing their unique animal sounds— for instance, pigs oink while cats meow.
An abstract method is defined within an abstract class and lacks a body It must be implemented in all non-abstract classes using the override keyword Once overridden, the abstract method exists in the non-abstract class, which can then be further derived in another class, allowing for additional overrides of the same abstract method.
An abstract class in C# serves as a means to achieve abstraction and is not intended for direct instantiation It can exist without any abstract methods, allowing for the definition of a base class within a class hierarchy Essentially, an abstract class is an incomplete or special class that cannot be instantiated, designed to provide a blueprint for derived classes Its primary purpose is to establish rules that derived classes must follow when inheriting from the abstract class.
We can use an abstract class as a base class and all derived classes must implement abstract definitions
To utilize interface methods in C#, a class must implement the interface, similar to inheritance, by using the colon (:) symbol The implementing class provides the body for the interface methods, and it is important to note that the override keyword is not required when implementing an interface Interfaces serve as an alternative means of achieving abstraction in C#.
An interface is a completely "abstract class", which can only contain abstract methods and properties (with empty bodies)
I have recently signed a contract with FPT Greenwich University to lead a team of programmers in developing a Product Management System This system will feature an application for storing product listings, allowing users to input and manage information about students and lecturers, including their ID, name, and industry Users will have the ability to correct or delete any incorrect information and view a comprehensive list of all system objects The development of this system is being carried out using the C# programming language.
My Product Management System includes the following features:
- 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
The ShowMenu() method displays the value to be modified, followed by invoking the DoTask() method to implement that change, with the return value of DoTask() assigned to the variable choice This entire process is encapsulated within a while(true) loop, which continues until choice equals 0, at which point the loop terminates.
Menu():To print the value to be changed
To implement a user selection feature, utilize a switch-case structure to correspond to specific functions Options 1, 2, and 3 will invoke the Save() method, passing a designated message as illustrated in the figure Selecting option 0 will display "Back to menu," while any choices outside of 0, 1, 2, or 3 will prompt the user with "Invalid choice, please try again!!!"
The Save() function receives parameters from DoTask() to execute the appropriate action, primarily aimed at confirming with the user whether they are certain about modifying the data.
- Abstract class includes two attributes, name and, subject, with an access level of protected
- Constructor that assigns values to two attributes
Overridden method ToString() to provide externally Observer's name
- Constructors have parameters that indirectly assign values to attributes via": base( )"
To override the Update() method, calculate the total population, number of cases, and number of deaths across all wards Then, compute the morbidity and mortality rates, and call the Show(rate, rateDie) function to display these rates effectively.
- Show(): To Displays morbidity and mortality rates
- GetState(): Calculates the ratio between the total number of red and green areas over the total number of districts in the subject and returns the state corresponding to that
- Constructors have parameters that indirectly assign values to attributes via ": base( )"
- Overriding the Update method in the Update function will call the GetState(), SetSatus(), Show() functions to print a table of subject information after the calculation
-ShowO:Print out full information, the state of each ward and the state of the subject
- Constructors have parameters that indirectly assign values to attributes via ": base( )"