Assignment 1 for Advanced Programming 1651, Assignments of C Sharp Programming

Assignment 1 for Advanced Programming 1651

Typology: Assignments

2021/2022

Available from 07/29/2022

tri-minh-1
tri-minh-1 🇻🇳

4.7

(144)

36 documents

1 / 18

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ASSIGNMENT 1 FRONT SHEET
Qualification
BTEC Level 5 HND Diploma in Computing
Unit number and title
Unit 20: Advanced Programming
Submission date
Date Received 1st submission
Re-submission Date
Date Received 2nd submission
Student Name
PHAN MINH TRI
Student ID
GCD201632
Class
GCD0904
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
Grading grid
P1
P2
M1
M2
D1
D2
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12

Partial preview of the text

Download Assignment 1 for Advanced Programming 1651 and more Assignments C Sharp Programming in PDF only on Docsity!

ASSIGNMENT 1 FRONT SHEET

Qualification BTEC Level 5 HND Diploma in Computing

Unit number and title Unit 20: Advanced Programming

Submission date Date Received 1st submission

Re-submission Date Date Received 2nd submission

Student Name PHAN MINH TRI Student ID GCD

Class GCD0904 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

Grading grid

P1 P2 M1 M2 D1 D

Summative Feedback:Resubmission Feedback:

Grade: Assessor Signature: Date:

Lecturer Signature:

Table of Contents

  • CHAPTER 1 – Introduction
  • CHAPTER 2 – OOP General Concepts
    • I. Object – oriented Programming (OOP)..........................................................................................................................
        1. Definition
        1. The benefits of OOP?
        1. Criticism of OOP........................................................................................................................................................
    • II. General concepts of OOP
    • III. Characteristics of OOP
        1. Encapsulation
        1. Abstraction
        1. Inheritance
        1. Polymorphism
    • IV. Types of relationships in Object – Oriented Programming (OOP)
        1. Dependency
        1. Association
        1. Aggregation
        1. Composition
        1. Inheritance
  • CHAPTER 3 – OOP Scenario..................................................................................................................................................
    • I. Encapsulation
        1. Scenario
        1. Class diagram
    • II. Abstraction
        1. Scenario
        1. Class diagram
    • III. Inheritance
        1. Scenario
        1. Class diagram
    • IV. Polymorphism
        1. Scenario
        1. Class diagram
  • References................................................................................................................................................................................
  • Figure 1: Example of Structure of OOP Table of Figures
  • Figure 2: Access Modifier
  • Figure 3: Dependency
  • Figure 4: Binary Association
  • Figure 5: Unary Association......................................................................................................................................................
  • Figure 6: Aggregation
  • Figure 7: Composition
  • Figure 8: Class diagram of Encapsulation
  • Figure 9: Class diagram of Abstraction.....................................................................................................................................
  • Figure 10: Class diagram of Inheritance
  • Figure 11: Class diagram of Polymorphism
  • Imperative programming: this focuses on function rather than models and includes C++ and Java
  • Declarative: This programming style includes statements stating the job or intended consequence but

not how to do it. Prolog and Lisp are two examples of programming languages.

  • Logical programming: This strategy, which is primarily based on formal logic and use languages like

as Prolog, consists of a collection of sentences that represent facts or rules about a problem area. It

focuses on problems where rule-based logical inquiries might help.

II. General concepts of OOP

❖ Classes are data types that are established by the user and serve as the design for individual objects,

properties, and actions.

❖ Objects are instances of a class that are formed with specified data. Object can be real-world objects or

abstract entities. When a class is first formed, the description is the sole object specified.

Figure 1 : Example of Structure of OOP

❖ Methods are terms used by programmers to define an object's activities. Methods are specified functions

within a class. Each method begins with a reference to an instance object, to which subroutines are

connected.

❖ Attributes are defined in the class template and describe an object's state. Data will be saved in the attributes

field of objects. Class characteristics are owned by the class.

III. Characteristics of OOP

  1. Encapsulation

❖ This concept asserts that all critical information is held within an object and just a subset of it is exposed.

Other objects do not have access to or jurisdiction over this class. It improves application security and

prevents inadvertent data damage.

❖ Type member access modifiers determine which code has access to a certain type of member.

Figure 2 : Access Modifier

❖ Examples in class Person with their properties

  1. Inheritance

❖ OOP allows developers to operate within the constraints of a single language while still preserving a distinct

hierarchy. Classes can reuse code from other classes, allowing developers to construct reusable code.

❖ Inheritance Implementation

interface IMyInterface

void MethodToImplement();

Interface Example: IDisposable interface

Interface Implementation

class InterfaceImplementer: IMyInterface

static void Main()

InterfaceImplementer iImp = new InterfaceImplementer();

iImp.MethodToImplement();

public void MethodToImplement()

Console.WriteLine("MethodToImplement() called.");

  1. Polymorphism

❖ Polymorphism allows various kinds of objects to use the same interface. A child class is established that

expands the parent class's capabilities. The software determines whether meaning or usage is required for

each execution of that object from a parent class, avoiding the requirement for duplicating code.

❖ Polymorphism Implementation

IV. Types of relationships in Object – Oriented Programming (OOP)

  1. Dependency

❖ Dependency is a connection formed when objects of one class interact momentarily with objects of another

class. Normally, multiplicity makes little sense on a dependency.

Figure 3 : Dependency

❖ Example: I create 2 class Truck and Car. In class Truck, there has Beep ()` function and class Car use again

that function. So, class Car depend on class Truck to work

  • Class diagram
  • Code example
  • Class diagram
  • Code example
  1. Composition

❖ Composition is a "part-of" connection with a strong association. To put it another way, composition occurs

when one class owns and includes objects from another class.

Figure 7 : Composition

  • Example: Both classes are regular classes, but the DataMigrator class uses an instance of the Logger

class inside of it. It’s the same as calling one function from inside another. Class diagram

  • With inheritance we would have access to everything in the Logger class. However, with composition

we only have access to code that we specified. We have access to the Logger class, but only indirectly

  • Example code

CHAPTER 3 – OOP Scenario

I. Encapsulation

  1. Scenario

❖ To apply encapsulation in my program, I allowed it to create a new object based on its properties. and have

a higher class that inherits that class and creates additional method. i will use the access modifier to allow

access to some parts, the rest I will hide it

  1. Class diagram Figure 8 : Class diagram of Encapsulation

❖ There are two classes: the person class (parent class) and the employee class (children class). Id, Name and

Age, which are kept private, are properties of person class, and it has the function displayInfo(). The

employee class has the same properties and methods as the Person class, but it is added a new property

which is branch, and an extra method which is showBranch().

II. Abstraction

  1. Scenario

❖ I'll design a Shape class as an abstract class to establish an abstract where every derived shape classes may

have their own area. According to the abstract method, they will use the same technique with different

implementations.

  1. Class diagram Figure 9 : Class diagram of Abstraction

❖ This shows the class diagram of Shape, an abstract class containing the abstract function area(), and Square,

a class inherited from Shape, with the side field and method area overriding from Shape.

III. Inheritance

  1. Scenario

❖ To explain OOP's inheritance feature, I will use the cat class, which is a child class of the animal class.

Objects produced from the cat class can use the Animal class's property and method as long as they are

accessible.

  1. Class diagram Figure 10 : Class diagram of Inheritance

❖ I have a Cat class that inherits from an Animal class to show inheritance. Because of the Name variable

inherited from the Animal class, I may specify a new cat's name and reuse the Eat function. I can also add

a MakeSound method to my cat class ()