Tải bản đầy đủ (.pdf) (65 trang)

1651 assignment 2 (pass)

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (1.8 MB, 65 trang )

Higher Nationals in Computing

Unit 19:
ASSIGNMENT 2
Advanced Programming (1651)

Assessor name: LE NGOC THANH
Learner’s name: Đào Vĩnh Khang
ID: GCS200222
Class: GCS0905B
Subject code: 1651
Assignment due:

Assignment

submitted:


ASSIGNMENT 2 FRONT SHEET
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

Re-submission Date

14-02-2022

Date Received 2nd submission

Student Name

DAO VINH KHANG

Student ID

GCS200222

Class

GCS0905B

Assessor name

LE NGOC THANH

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
P1

P2

M1

M2

D1

D2

KHANG


❒ Summative Feedback:

Grade:
Signature & Date:

❒ Resubmission Feedback:

Assessor Signature:

Date:


ASSIGNMENT 2 BRIEF
Qualification

BTEC Level 5 HND Diploma in Business


Unit number

Unit 20: Advanced Programming

Assignment title

Examine and design solutions with OOP and Design Patterns

Academic Year

2021 - 2022

Unit Tutor

LE NGOC THANH

Issue date

28 November 2022

Submission date

IV name and date
Submission Format:
Format:

The submission is in the form of a group written report. This should be written in a concise,
formal business style using single spacing and font size 12. You are required to make use of
headings, paragraphs and subsections as appropriate, and all work must be supported with
research and referenced using the Harvard referencing system. Please also provide a

bibliography using the Harvard referencing system.
Submission Students are compulsory to submit the assignment in due date and in a way requested by
the Tutors. The form of submission will be a soft copy in PDF posted on corresponding course
of />Note:
The Assignment must be your own work, and not copied by or from another student or from
books etc. If you use ideas, quotes or data (such as diagrams) from books, journals or other sources, you
must reference your sources, using the Harvard style. Make sure that you know how to reference
properly, and that understand the guidelines on plagiarism. If you do not, you definitely get fail
Assignment Brief and Guidance:
Scenario: You have recently joined a software development company to help improve their documentation of their in-houses
software libraries which were developed with very poor documentation. As a result, it has been very difficult for the company
to utilise their code in multiple projects due to poor documentation. Your role is to alleviate this situation by showing the
efficient of UML diagrams in OOAD and Design Patterns in usages.
Tasks
You and your team need to explain characteristics of Object-oriented programming paradigm by applying Object-oriented
analysis and design on a given (assumed) scenario. The scenario can be small but should be able to presents various
characteristics of OOP (such as: encapsulation, inheritance, polymorphism, override, overload, etc.).
The second task is to introduce some design patterns (including 3 types: creational, structural and behavioral) to audience by
giving real case scenarios, corresponding patterns illustrated by UML class diagrams.


Learning Outcomes and Assessment Criteria
Pass

Merit

Distinction

LO1 Examine the key components related to the object-orientated programming paradigm, analysing
design pattern types


P3 Build an application M1 Determine a design pattern D1 Analyse the relationship
derived from UML class from each of the creational, between the object-orientated
structural and behavioural pattern paradigm and design patterns.
diagrams..
types.
LO2 Design a series of UML class diagrams
P4 Discuss a range of design
patterns
with
relevant
examples
of
creational,
structural

M2 Define class diagrams for specific
design patterns using a UML tool.

D2 Define/refine class diagrams
derived from a given code scenario
using a UML tool.


Table of contents
Contents
ASSIGNMENT 2 FRONT SHEET ..................................................................................... 2
ASSIGNMENT 2 BRIEF .................................................................................................................... 4
Table of contents .................................................................................................................................. 6
I.


Introduction .................................................................................................................................. 1

1. Characteristics of the object-orientated paradigm........................................................................... 1
-

Abstraction: ............................................................................................................................... 3

-

Inheritance: ............................................................................................................................... 6

-

Polymorphism : .......................................................................................................................... 8

-

Abstract classes ......................................................................................................................... 9

-

Interfaces: ................................................................................................................................ 10

2. Coding Managing School System: ................................................................................................... 11
1. What is design pattern ................................................................................................................ 34
2. When use design patterns .......................................................................................................... 35
3. Categorization of patterns .......................................................................................................... 35
3.1Creational Pattern .................................................................................................................. 37
3.2


Structure Patterns ............................................................................................................ 43

3.3

Behavior Patterns ............................................................................................................. 52


I. Introduction
Based on the class diagram created in assignment 1, in this assignment I will build an application derived from
that UML class diagram. Then, I will cover a series of design patterns with relevant examples of creative,
structural, and behavioral patterns.
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
-

Object/Class:


Explanation:
- Here you can see the Object class at the top of the type hierarchy. Type 1 and Type 2 are reference types.
Class 1 inherits the Object class while Class 2 inherits it directly using Class 1. Struct1 is a value type that
implicitly inherits the Object class through the System.ValueType type.

Result:



-

- Abstraction:

-

If you observe the above code, we defined a Shape class with
required fields, properties, and methods with the public, private access modifiers to
achieve an abstraction functionality by hiding and exposing some of
the methods and properties based on our requirements.

-

Here, the public modifier allows defined fields, properties, and methods to access outside
of the class. The private modifier is used to hide or restrict access to
required fields, properties, and methods outside of class.

-

By creating an instance of the Shape class, we can access
defined fields, properties, and methods.

3


-

Result:


-

Encapsulation:

Explanation:

4


-

-

In the above program the class Inheritance is encapsulated as the variables are
declared as private. To access these private variables we are using the Name
and Age accessors which contains the get and set method to retrieve and set
the values of private fields. Accessors are defined as public so that they can
access in other class.

Result:

5


-

- Inheritance:

6



-

Explantion:
- Here we are using labrador to access Name and display() then Inheritance. This can
happen because the derived class inherits all the fields and methods of the base class. Also,
we have access to the Field Name inside Inheritance class method.
-

Result:

7


Polymorphism :

Explaintion:
- think of a base class called Animal that has a method called animalSound(). Derived classes of Animals
could be Pigs, Cats, Dogs, Birds - And they also have their own implementation of an animal sound (the
pig oinks, and the cat meows, etc.)::

8


-

Result:

Abstract classes


Explaintion:
Abstract Method: A method that is declared abstract, has no “body” and is declared inside the abstract
class only. An abstract method must be implemented in all non-abstract classes using the override
keyword. After overriding, the abstract method is in the non-Abstract class. We can derive this class in
another class, and again we can override the same abstract method with it.

9


Abstract Class: This is the way to achieve the abstraction in C#. An Abstract class is never intended to be
instantiated directly. An abstract class can also be created without any abstract methods, We can mark a
class abstract even if doesn’t have any abstract method. The Abstract classes are typically used to define
a base class in the class hierarchy. Or in other words, an abstract class is an incomplete class or a special
class we can’t be instantiated. The purpose of an abstract class is to provide a blueprint for derived
classes and set some rules that the derived classes must implement when they inherit an abstract class.
We can use an abstract class as a base class and all derived classes must implement abstract definitions.

-

Result:

Interfaces:

10


Explaintion:
- To access the interface methods, the interface must be "implemented" (kinda like inherited) by
another class. To implement an interface, use the : symbol (just like with inheritance). The body of

the interface method is provided by the "implement" class. Note that you do not have to use the
override keyword when implementing an interface:Another way to achieve abstraction in C#, is
with interfaces.
An interface is a completely "abstract class", which can only contain abstract methods and
properties (with empty bodies)

-

Result:

2. Coding Managing School System:
I have just signed a contract with FPT Greenwich University and am about to be appointed as a
project leader for a group of programmers to develop the company's Product Management
System. In this Product Management System, I was asked to create an application to store
product listings and product listings. With the system, users can enter information about
students and lecturers such as id, name, industry, & into the system, correct the information if
it is wrong or completely delete the information of the product. See a list of all system9s
objects. To create this system, I used C# language.
My Product Management System includes the following features:
1) Add an object
2) Show object list
3) Update object
11


4) Delete an object
5) Add a major
6) Show majors
7) Score update
8) deleted oject


Ward.cs

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.
12


-

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.

-

DoTask: ask the user to enter a selection each choice I use Switch-case to correspond to a
function. Option 1,2,3 will call the Save() method and pass in that method a message as shown in the
figure. Case 0 will print "Back to meu" and choices other than 0.1,2,3 will print "Invalid choice
please try again!!!".
13


-

Save():Takes parameters from DoTask() passed in to perform the corresponding function, the
purpose of this function is to ask the user if he is sure to change the data.
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
14


- Have a Subject
- Inherit class MyObserver through":".
- Constructors have parameters that indirectly assign values to attributes via":
base(...)".
15


- 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

ProvincialChairman

16



- Have a Subject
- Inherit classMyObserver through "-"
- 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

17


ratio.
- 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.

Fanpage.cs

18


- 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.
-Main(): Print information of each ward.
-Footer Print the subject's update time.


19


Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×