Docsity

Advanced Progaming Asm 1, Assignments of Computer Science

Toggle sidebar
bg1
ASSIGNMENT 1 FRONT SHEET
Qualification
BTEC Level 5 HND Diploma in Computing
Unit number and title
Unit 20: Advanced Programing
Submission date
Date Received 1st
submission
Re-submission Date
Date Received 2nd
submission
Student Name
Nguyen Huu Hieu
Student ID
GCD201855
Class
GCD1001
Assessor name
Pham Thanh Son
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
Hieu
Grading grid
P1
P2
P3
P4
M1
M2
D1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30

Partial preview of the text

Download Advanced Progaming Asm 1 and more Assignments Computer Science in PDF only on Docsity!

ASSIGNMENT 1 FRONT SHEET

Qualification BTEC Level 5 HND Diploma in Computing

Unit number and title Unit 20 : Advanced Programing

Submission date Date Received 1st submission

Re-submission Date Date Received 2nd submission

Student Name Nguyen Huu Hieu Student ID GCD

Class GCD1001 Assessor name Pham Thanh Son

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 Hieu

Grading grid

P1 P2 P3 P4 M1 M2 D

Summative Feedback:Resubmission Feedback:

Grade: Assessor Signature: Date:

Internal Verifier’s Comments:

Signature & Date:

Figure 40:Snippet Code 29 ................................................................................................................................... Figure 41:Snippet Code 30 ................................................................................................................................................................... 42 Figure 42:Snippet code 31.................................................................................................................................................................... 42

I. INTRODUCTION

Programming languages that provide advanced features are used to build and develop software more

efficiently. This improves the performance of the application, as well as the readability and scalability of the

code, and can also cut costs. Many commercial or entertainment applications available today, whether they

are for work or play, will use one or more design patterns when they are created. A design pattern is a

description of how to solve a problem that can be used in many different situations. Design patterns

provide a standard and case-specific terminology. Therefore, it can help you to gain more knowledge about

object-oriented programming and improve software design and reusability. So, in this Assignment 1, I'm

going to provide insights to help people gain a deeper understanding of how to create effective apps and

improve app performance. Here are some of the categories that I will clarify in this report.

"Object-Oriented Programming" and "Data Abstraction" have both become overused buzzwords.

Unfortunately, not everyone agrees on what they signify. In this assignment, I will describe object-oriented

programming properties like as encapsulation, inheritance, polymorphism, and so on, as well as various

class interactions. Following that, I'll create a class diagram based on a certain code scenario

  • The characteristics of the object-orientated paradigm as well as the various class relationships.
  • Design and build class diagrams using a UML tool
  • Determine a design pattern from each of the creational, structural and behavioural pattern types
  • Define class diagrams for specific design patterns using a UML tool.
  • Analyse the relationship between the object-orientated paradigm and design patterns
  • Define/refine class diagrams derived from a given code scenario using a UML tool

II. OOP GENERAL CONCEPTS (P1)

1. Object-oriented programming (OOP)

According to Object-oriented programming is an object-centric programming technique that allows

programmers to create objects in code to abstract away real-life objects. There are many design patterns

that are based on this. On the other hand, OOP focuses on the things that developers want to manipulate

rather than the logic that is needed to manipulate them. This is a good way to write programs that are big

and complicated and that need to be changed or kept up to date. This includes programs for design and

Figure 1 :OOP Concept

2. General concepts of OOP

A. Class

A class is a model, blueprint, or prototype of an object that defines or specifies all of the object's attributes A user-created object-

oriented programming framework called Class is employed. It displays the attributes and functions that all objects belonging to this

class share. Real things are called objects. Information and exercises covered in the lesson are interchangeable. Making a class allows

one to think of objects of the same type in terms of the data that is known about them and the operations that can be performed on

that data.

  • Modifiers:A class can be public or private, for example. The class’s default modifier is internal.
  • Class keyword: The class keyword is used to declare the type class.
  • Class Identifier: The variable of type class is supplied. The identifier (or class name)

should begin with an initial letter that is capitalized by convention.

  • Super class vs. base class: If there is one, the name of the class's parent (superclass),

preceded by the: (colon). This is entirely optional.

  • Interfaces: A comma-separated list of any interfaces implemented by the class

followed by the: (colon). A class can implement many interfaces. This is entirely

optional.

  • Body: The body of the class is surrounded by (curly braces).

Here is a class description example:

Figure 2 :Class

The code in the aforementioned graphic describes the Name, Age, ID, Address, and GetInfor() method to obtain a citizen's information, which

are the most typical characteristics of a citizen. We can rely on those characteristics to deploy objects that share characteristics with citizens,

like students, workers, etc.

B. Object:

An object is a class entity or instance. Objects are generally physical entities, although they can also be intellectual entities. Each object has a

state and a set of behaviors. An object is a concrete instance of a class. It is the things that appear around us in the real world that exhibit their own

int thamso1, many parameters are separated by commas ,.

  • Finally, the function body { } , which contains the C# statements that when the function is called, it will execute according to

the logic of the code from start to finish, or when the return; statement is encountered. When a function has a return type, a

return value statement is required in the function body

Figure 4 : Method

D. Constructor.

A constructor is a method subtype. This method is called automatically when the object is created. Constructors do not

return values.

The constructor's objective is to begin the state of an object. Constructors have the same name as the class.

Constructors can be overloaded since they are methods. Constructors are not inheritable. They are named by the order in

which they were inherited. C# will give an implicit default constructor if we do not specify a constructor for a class. If no

constructor is specified, no default is supplied.

Important Facts to Remember About Builders:

  • The constructor of a class must have the exact name as the class in which it sits.
  • At the same time, a constructor cannot be abstract, final, or synchronized.
  • A class can only have one static constructor.
  • There is no return type for a constructor, not even void.
  • A static constructor cannot be a parameterized constructor.
  • There can be an infinite number of constructors in a class
  • In constructor declarations, access modifiers can be used to limit who else can invoke the constructor.

2. Characteristics of OOP

  1. Encapsulation
  • Encapsulation: An object's internal processing characteristics can be hidden through encapsulation, preventing other objects

from directly altering the state. can only take action using that object's public methods.

  • Access Modifier:

C# access modifiers, also known as specifiers, are keywords that are used in C# applications to indicate the accessibility or

scope of variables and functions.

OOP Scenario for access modifier.

  • Private Access Modifier.

When you declare a field with the private access modifier, it can only be accessed inside the same class.

When you use the public access modifier to define a field, it does become readable to all.

Figure 8 : Public Figure 9 : Public code

Figure 10 : result

  • Protected Access Modifier. The code is available within the same class or a class derived from that class. In this access modifier I have created 2 table which is School and Student. The name protected field is only accessible to the School and The Inherited classes. The function, however, cannot be accessible through the inherited class. Figure 11 :Protected

Figure 13 : result

  • Property: As mentioned above, Properties are class members that allow access to public data inside of the class. Properties

declared as Public can be read-only, write-only or both read and write by declaring both the get and set code for the Field

  • Scenario: In this scenario, I will mask the Fields with encapsulation by assigning their Fields with the Access Modifier Private Figure 14 :Encapsulation Diagram
  • I. INTRODUCTION
  • II. OOP GENERAL CONCEPTS (P1)
      1. Object-oriented programming (OOP)
      1. General concepts of OOP
      • A. Class
      • B. Object:
      • C. Method:
      • D. Constructor.
      1. Characteristics of OOP
        1. Encapsulation
      • OOP Scenario for access modifier.
        1. Inheritance
        1. Polymorphism
        1. Abstraction
  • III. RELATIONSHIPS BETWEEN CLASSES (P1+P2)
      1. Introduction
      1. Association
      1. Aggregation
      1. Composition
      1. Generation
  • REFERENCES
  • Figure 1:OOP Concept Table of Figures
  • Figure 2:Class..........................................................................................................................................................................................
  • Figure 3: Object
  • Figure 4: Method..................................................................................................................................................................................
  • Figure 5:Encapsulation Diagram
  • Figure 6:Snippet code 1........................................................................................................................................................................
  • Figure 7:Snippet Code
  • Figure 8:Snippet Code
  • Figure 9:Snippet Code
  • Figure 10: Snippet Code
  • Figure 11:Snippet Code
  • Figure 12:Snippet Code
  • Figure 13 :Inheritance Diagram
  • Figure 14:Snippet Code
  • Figure 15 : Snippet Code
  • Figure 16 :Snippet Code
  • Figure 17 :Snippet Code
  • Figure 18:Polymorphism Diagram........................................................................................................................................................
  • Figure 19:Snippet Code
  • Figure 20:Snippet Code
  • Figure 21:Snippet Code
  • Figure 22:Snippet Code
  • Figure 23:Snippet Code
  • Figure 24: Snippet Code
  • Figure 25:Abstract Diagram
  • Figure 26:Snippet Code
  • Figure 27:Snippet Code
  • Figure 28:Association Diagram.............................................................................................................................................................
  • Figure 29:Snippet Code
  • Figure 30:Snippet Code
  • Figure 31:Snippet Code
  • Figure 32:Snippet Code
  • Figure 33:Aggregation Diagram
  • Figure 34:Snippet Code
  • Figure 35:Snippet Code
  • Figure 36:Snippet Code
  • Figure 37:Snippet Code
  • Figure 38:Composition diagram
  • Figure 39:Snippet Code
  • Figure 15 :Snippet code
  • Figure 16 :Snippet Code
  • Figure 17 :Snippet Code

Figure 19 : Snippet Code 5

  • Keyword Virtual: When a method or property declaration is modified using the virtual keyword, the modified declaration is referred to as a virtual member. An overriding member in a derived class can alter how a virtual member is implemented. The characteristics of the keyword Virtual are demonstrated in the example below.

Figure 20 :Snippet Code 6

  • Keyword Sealed: A class that has the sealed keyword provided is a class that forbids inheritance. Whenever a method is provided with the sealed keyword, overriding is not permitted.