You are on page 1of 29

Higher Nationals in Computing

Advanced Programming - 1651

ASSIGNMENT
No.1

Learner’s Name: HUYNH NHAT NAM


Assessor Name: NGUYEN VAN SON
Class: .........GCS0805B........
ID: .....GCS190293....
Assignment due:
Assignment submitted: 2 0 J U N E 2 0 2 1

ASSIGNMENT 1 FRONT SHEET


Qualification BTEC HND Diploma in Computing and Systems Development

Unit number and


Unit 20: Advanced Programing
title
Assignment
Assignment due
submitted

Learner’s name Assessor name

Learner declaration:
I certify that the work submitted for this assignment is my own and research sources are fully
acknowledged.
Learner
Date
signature

Grading grid
P1 P2 M1 M2 D1 D2

Assignment title Assignment 1: OOP principles, features and design.

In this assignment, you will have opportunities to provide evidence against the following
criteria.
Indicate the page numbers where the evidence can be found.

Assessment Expected evidence Task Assessor’s Feedback


criteria no.

LO1. Understand the principles of object oriented programming.

- Object/Class,
P1. Discuss the - Abstraction,
principles;
characteristics - Encapsulation,
and - Inheritance, 1
features of object
orientated - Polymorphism,
programming. - Abstract classes,
- Interfaces

LO2. Be able to design object oriented programming solutions.


P2. Identify the - Use-case diagrams
objects and data - Class diagrams
and file structures
required to - Pseudo-codes
implement a given - Activity Diagrams.
design. 2
- Judgments for features
have been
Design an object included/excluded and
orientated why certain features have
programming been used over others
solution for a (where applicable)
given problem.
Assessment criteria Expected Feedback
Evidence (note on Merit/Distinction if applicable)
Merit descriptor No.
(M1)
Merit descriptor No.
(M2)
Distinction descriptor
No. (D1)
Distinction descriptor
No. (D2)

Summative feedback:

Assessor’s Date:
Signature:

ASSIGNMENT 1 BRIEF

Unit Number and Title 20: Advance Programming


Academic Year 2021
Unit Tutor Nguyễn Văn Sơn
Assignment Title Assignment 1
Issue Date
Submission Date
IV Name & Date

Pass Merit Distinction


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

P1 Examine the M1 Determine a design D1 Analyse the relationship


pattern from each of between the object-orientated
characteristics of the
object-orientated the creational, paradigm and design patterns.
paradigm as well as the structural and
various class behavioural pattern
relationships. types.

LO2 Design a series of UML class diagrams

P2 Design and build M2 Define class D2 Define/refine class diagrams


class diagrams using a diagrams for specific derived from a given
UML tool. design patterns using a code scenario using a UML tool.
UML tool.

Scenario

You’ve just made a contract with FPT Academy International, and are
about to be appointed as a Project Leader for a group of programmers
to develop its Student Management System.

In this Student Management System, you are required to create an


application to store list of students and list of lecturers. Following
information are to be stored for each student:

- stdId: The student ID of the form like GTxxxxx or GCxxxxx (x: is a


digit)
Specific - stdName: Student name
requirements - stdDoB: Student date of birth
- stdEmail: Student email
(see Appendix for
- stdAddress: Student address
assessment criteria
- stdBatch: The batch (class) of the student
and grade
descriptors)
Following information are to be stored for each lecturer:

- lecId: Lecturer ID with 8 digits (fixed)


- lecName: Lecturer
- lecDoB: Lecturer date of birth
- lecEmail: Lecturer email
- lecAddress: Lecturer address
- lecDept: Lecturer department (e.g., Computing, Business, etc)

This application will need to provide following functionalities via a


menu
=======================

1. Manage Students
2. Manage Lecturers
3. Exit

=======================

Please choose:

When user selects 3, the program will exit.

When user selects 1, the program will display submenu for managing
students:

=======================

1. Add new student


2. View all students
3. Search students
4. Delete students
5. Update student
6. Back to main menu

=======================

Please choose:

When user selects 2, the program will display submenu for managing
lecturers:

=======================

1. Add new lecturer


2. View all lecturers
3. Search lecturers
4. Delete lecturers
5. Update lecturer
6. Back to main menu

=======================

Please choose:

For the submenu:

When user chooses 1, program will prompt user to input


student’s/lecturer’s information (specified previously). After that,
program will validate the input data and if they are all valid, program
will add a new student/lecturer to the current list of students/lecturers.
Program should inform to the user corresponding messages.

When user chooses 2, the program will list all the students/lecturers to
the screen, each student/lecturer in a row and student’s/lecturer’s data
fields are separated by ‘|’.

When user chooses 3, the program will ask user to input


student’s/lecturer’s name to search for, the user can just type part of
the name in order to search for complete student/lecturer information.

When user chooses 4, program will ask user to input student/lecturer


id to delete the student/lecturer with the specified id if it exists,
otherwise, it will display a message to inform users that the
student/lecturer with such id doesn’t exist.

When user chooses 5, program will first ask user to input


student/lecturer id to update, once inserted and a student/lecturer with
the inserted id exists, it will display current data for each field of the
student/lecturer and user can type in new data to update or just press
enter to keep the current data for the field.

When user chooses 6, program will back to the main menu.


Task 1
Produce a written, self-learning course for managers/senior developers
that explain the principles and features of OOP and that show how
OOP is good for code re-use. You can include appropriate sample Java
code where it aids your points and/or provides further clarification.
Ensure that any diagrams that are included have captions and are
referenced in the text.
Hint: You must include the following terms
- Object/Class,
- Abstraction,
- Encapsulation,
- Inheritance,
- Polymorphism (Overloading and Overriding),
- Abstract classes,
- Interfaces

Task 2
Problem Analysis, for the scenario above.
You need to produce a full design for the requirements given. The
design must include
- Use-case diagrams for the most important features;
- Class diagrams for all objects identified as well as class relationships.
- Pseudo-code for the Algorithms for the main functionalities (3
flowcharts for most complex functions).
Example code can be used to help clarify OOP features.

For the assignment assessments, you are required to:


Student
1. Produce a design in UML that fully utilizes OOP principles and
guidelines
features. (Use case, class diagrams, collaboration diagrams etc.).

Submission
Students are expected to submit hard copy of assignment
requirements

Grade Descriptor
PASS criteria

LO Learning outcome AC In this assessment you will have the Task


(LO) opportunity to present evidence that no.
shows you are able to:

LO1 Examine the key 1 Examine the characteristics of the 1


components related object-orientated paradigm as well as
to the object- the various class relationships.
orientated
programming
paradigm, analysing
design pattern types
LO2 Design a series of Design and build class diagrams
UML class diagrams using a UML tool.

In addition to the above PASS criteria, this assignment gives you the opportunity to submit
evidence in order to achieve the following MERIT and DISTINCTION grades
Indicative
Grade Descriptor Contextualization
characteristic/s
M1 Determine a design pattern from
each of the creational, structural
and behavioural pattern types.
M2 Define class diagrams for specific
design patterns using a UML tool.
D1 Analyse the relationship between
the object-orientated paradigm and
design patterns.
D2 Define/refine class diagrams
derived from a given code scenario
using a UML tool.

This brief has been verified as being fit for purpose

Internal
Signature Date
Verifier 1

Internal
Signature Date
Verifier 2
INTRODUCTION
Advance programming is a subject that contain all programming language paradigms
and Object-oriented programming is a programming language model organized around
the objects rather than “action” and data rather than logic. Historically, a program has
been viewed as a logical procedure that takes input data, processes it, and produces
output data.
In this assignment I have required to develop software system for Students and Lectures
Management System before that I have to understand the Advance Programming
principles and able to designing the object- oriented programming solution.

1. Characteristics of the object-orientated paradigm (P1)

What is OOPs (Object-oriented programming system)?

Object-Oriented Programming (OOP) System is a programming paradigm based on the


concept of using classes and objects in your programming code. Object-Oriented
Programming (OOP) used to structure a programming language into simple, reusable pieces
of code that usually known as classes, which we can use as a user define Data Type to create
instances of objects.

Characteristics of Oop’s
OOPs ( Object-oriented programming system ) has many Characteristics like:
• Class
• Objects
• Data Abstraction
• Data Encapsulation
• Inheritance
• Polymorphism

List of Top OOPs base languages:


• C++
• Java
• C#
• Java Script
• Python

1.1. Object/Class
What is an object?

What are the Objects in OOPs ( Object-oriented programming system )?


• Objects are basic building blocks for designing programs.
• An object is a collection of data members and associated member functions.
• An object may represent a person, place or a table of data.
• Each object is identified by a unique name. Each object must be a member of a
particular class.
• Example: chair, table, whiteboard are the objects of the class (class).
The Objects are the key to understanding object-oriented program. In the real objects are the
entities from which the world is involved. Every this that occurs around the world is connected
to the interfaces between the objects in the world just as atoms, which are objects, associate to
form partials and larger objects, the interacting entries in the world can be thought of as relation
between and amongst both singular (atomic) as well as compound (composed) objects. For
each object that you see, ask yourself two questions the questions are given below:
1. “What is the possible states can this object is in?”
2. “What is the possible behavior can this object performs?”
Around the world objects are share two characteristics:
• State (properties) ‘ describe the characters
• Behavior (methods) ‘ what it can do or what done for it.

Following is an example of creating an object

Example

Create an object called "myObj" and use it to print the value of color:
class Car
{
string color = "red";

static void Main(string[] args)


{
Car myObj = new Car();
Console.WriteLine(myObj.color);
}
}
Another Example
public class Puppy {
public Puppy(String name) {
// This constructor has one parameter, name.
System.out.println("Passed Name is :" + name );
}
public static void main(String []args) {
// Following statement would create an object myPuppy
Puppy myPuppy = new Puppy( "tommy" );
}
}
Output:
Passed Name is :tommy

State
The state of an object includes all of the static properties of the object plus the current dynamic
values of each of these states. A state is distinctive or an inherent characteristic, quality, trait,
or feature that distribute to making an object uniquely. Word uses an attribute, or data member,
to refer to the state of an object.
Behavior
Behavior is how an object reacts and acts, in the terms of properties changes and interactions
with other objects. An operation is some action that one object performs upon another in order
to promote a reaction. The word called as method that uses to describe object method in java.
Entreating a method reasons the behavior to take place.
Some Example for state and behavior
• State Behavior
• Name Talking
• Color Walking
• Breed Barking
• Hungry Fetching

What is Class?
What are the Classes in OOPs (Object-oriented programming system)?
• The objects can be made user-defined data types with the help of a class.
• A class is a collection of objects that have identical properties, common behaviour and
shared relationship.
• Once the class is defined any number of objects of that class is created.
• Classes are user-defined data types A class can hold both data and functions.
• For example planets, sun and moon are the members of the solar system class.
The class is simply a representation of a type of object. The class is a design or plan or template
or a set of instructions to build a specific type of object. Each and Every object is built from a
class. Every class should be designed and programmed to complete one, and only one, thing.
Each and every class is designed to have only one single responsibility; many classes are used
to build an entire application.
Around the world the class describes three things.
• Name
• similar properties (attributes)
• common behavior (operations)
Classes create objects and objects use methods to communicate with them. A class is a
collection of fields and methods that operate on the data.

Example:
Create a Class
To create a class, use the class keyword:
Create a class named "Car" with a variable color:
class Car
{
string color = "red";
}

Another example:
public class Dog {
String breed;
int age;
String color;

void barking() {
}

void hungry() {
}

void sleeping() {
}
}

Different between object and class


Class
• A class is a description of properties which are common of an object
• A notion.
• A class could be said as a section of a system application.
• You define all the properties and functions
• Can create subclass
Object
• An object is a representation of a single instance
• An occurrence.
• An object is part of data and a program execution.
• Can’t create sub Object

1.2. Abstraction
What is Data abstraction in OOPs (Object-oriented programming system)?

Data abstraction refers to the process of representing essential features without including
background details or explanations.

It is referred to ad quality of dealing with ideas that events and it is basically dealing with
hiding details and show the essential thing to the user.
We will achieve abstraction in two ways and they are Abstract Class and Interface.
Abstract classes contain abstract keyword and if a class declared as abstract then cannot create
an object of an abstract class and it can contain abstract methods and concrete methods.
Abstraction is closely related to encapsulation, and, to some extent, it overlaps with it.
Briefly, abstraction provides a mechanism that exposes what an object does and hides how
the object does what it's supposed to do.
A real-world example of abstraction is a car. In order to drive a car, we don't really need to
know what the car has under the hood, but we need to know the data and behavior it exposes
to us. The data is exposed on the car's dashboard, and the behavior is represented by the controls
we can use to drive a car.
Abstract Classes and Methods
Data abstraction is the process of hiding certain details and showing only essential
information to the user.
Abstraction can be achieved with either abstract classes or interfaces (which you will learn
more about in the next chapter).
The abstract keyword is used for classes and methods:
• Abstract class: is a restricted class that cannot be used to create objects (to access it, it
must be inherited from another class).
• Abstract method: can only be used in an abstract class, and it does not have a body.
The body is provided by the derived class (inherited from).
An abstract class can have both abstract and regular methods:
abstract class Animal
{
public abstract void animalSound();
public void sleep()
{
Console.WriteLine("Zzz");
}
}

1.3. Encapsulation
What is Data encapsulation in OOPs (Object-oriented programming system)?

• The wrapping of data and function into a single unit is called data encapsulation.
• Data encapsulation enables data hiding and information hiding.

Encapsulation is one of the fundamental in OOP concept and in java it is a mechanism of


wrapping the data variables and code acting on the data methods together as a single unit. It
helps to create programs that are easier to maintain and debug.
Encapsulation is to declare variables with different access modifiers, such as private or
public. However, when using private variables in programming languages such as java. Declare
the variables of class as private, provide public setter and getter methods to modify and view
the variable values these are the ways to achieve encapsulation in java.
If we are using Encapsulation it will able to give
• Fields of class made read and write only
• Class will have control over what is stored in their fields.

Example Code For Encapsulation


package bcas.encap;
public class Encapsulation {
private String carType; private String model; private int year;
public int getYear() {
return year; }
public String getCarType() { return carType;
}
public String model() {
return model; }
public void setYear(int newYear) {
year = newYear;
}
public void setCarType(String newCarType) {
carType = newCarType;
}
public void setModel(String newModel) {
model = newModel;
}
}

•MainClass
packagebcas.encap;
public class EncapsulationDemo {
public static void main(String args[]) { Encapsulation encap = new Encapsulation();
encap.setCarType("Sedan"); encap.setYear(2018); encap.setModel("BMW");
System.out.println("Car Type Is : " +
encap.getCarType() + " Released Year Is : " +
encap.getYear());
}}

1.4. Inheritance
Inheritance (Derived and Base Class)

What is Inheritance in OOPs (Object-oriented programming system)?


• Inheritance is the process by which one object can acquire and the use of properties of
another object.
• The existing class is known as a base class or superclass.
• The new class is known as a derived class or subclass.
• The derived class shares some of the properties of the base class. Therefore a code from
a base class can be reused by a derived class.
The inheritance is concept of where the properties of the parent class inherited to child class.
It helps to reuse the codes in a good manner and used to establish relationship between different
classes.
For instance:
If we take the father and son the Father is a base class or super class and son is the child class
or derive class.
Some Types :
• Single Level Inheritance
• Multilevel Inheritanc
• Hierarchical Inheritance

In C#, it is possible to inherit fields and methods from one class to another. We group the
"inheritance concept" into two categories:
• Derived Class (child) - the class that inherits from another class
• Base Class (parent) - the class being inherited from
To inherit from a class, use the : symbol.
In the example below, the Car class (child) inherits the fields and methods from
the Vehicle class (parent):
Example

class Vehicle // base class (parent)

public string brand = "Ford"; // Vehicle field

public void honk() // Vehicle method

Console.WriteLine("Tuut, tuut!");

class Car : Vehicle // derived class (child)

public string modelName = "Mustang"; // Car field

}
class Program

static void Main(string[] args)

// Create a myCar object

Car myCar = new Car();

// Call the honk() method (From the Vehicle class) on the myCar
object

myCar.honk();

// Display the value of the brand field (from the Vehicle class) and
the value of the modelName from the Car class

Console.WriteLine(myCar.brand + " " + myCar.modelName);

1.5. Polymorphism (Overloading and Overriding)

What is Polymorphism in OOPs (Object-oriented programming system)?


• The ability of an operator and function to take.
• Multiple forms are known as polymorphism.
• The different types of polymorphism are operator
• overloading and function overloading.

Polymorphism has an ability to use same code with different types of objects and behave
differently with each. If we have a problem that is change behavior depending on concrete
objects and the solution for that is polymorphism.
Polymorphism allows to define one interface and have many implementations.
Method Overriding. – Two methods with same method name and parameters and overriding
allows a child class to provide a specific implementation of a method that is already provided
its parent class.
Method Overloading occurs when two or more methods in one class have the same method
name but different parameter

For example:

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.):

class Animal // Base class (parent)

public void animalSound()

Console.WriteLine("The animal makes a sound");

class Pig : Animal // Derived class (child)

public void animalSound()

Console.WriteLine("The pig says: wee wee");

class Dog : Animal // Derived class (child)

public void animalSound()

{
Console.WriteLine("The dog says: bow wow");

1.6. Abstract classes

Abstract Class
An abstract class is a class that is declared abstract — it may or may not include abstract
methods. Abstract classes cannot be instantiated, but they can be subclassed. An abstract class
may have static fields and static methods. When an abstract class is subclassed, the subclass
usually provides implementations for all of the abstract methods in its parent class. However,
if it does not, then the subclass must also be declared abstract.

An abstract method is a method that is declared without an implementation (without braces and
followed by a semicolon), like this:
1
abstract void sum(int a, int b);

Consider using abstract classes if any of these statements apply to your situation:
• You want to share code among several closely related classes.
• You expect that classes that extend your abstract class have many common methods or
fields or require access modifiers other than public (such as protected and private).
• You want to declare non-static or non-final fields. This enables you to define methods
that can access and modify the state of the object to which they belong.

1.7. Interfaces

An interface is just the declaration of methods of an object; it’s not the implementation. In
an interface, we define what kind of operation an object can perform. These operations are
defined by the classes that implement the interface. Interfaces form a contract between the class
and the outside world, and this contract is enforced at build time by the compiler.

For example:

// Interface

interface IAnimal

void animalSound(); // interface method (does not have a body)


}

// Pig "implements" the IAnimal interface

class Pig : IAnimal

public void animalSound()

// The body of animalSound() is provided here

Console.WriteLine("The pig says: wee wee");

class Program

static void Main(string[] args)

Pig myPig = new Pig(); // Create a Pig object

myPig.animalSound();

Consider using interfaces if any of these statements apply to your situation:


• You expect that unrelated classes would implement your interface. For example, the
interfaces Comparable and Cloneable are implemented by many unrelated classes.
• You want to specify the behavior of a particular data type, but not concerned about who
implements its behavior.
• You want to take advantage of multiple inheritances.
2. The various class relationships
Aggregation

Aggregation is a special case of association and a direct association between objects. If an


object has another object then it is an aggregation between it.

It is representing by Has-A relationship and in this both entries can survive them individually
it means ending one entity will not affect other entity.

We use aggregation because code reuse is a best achievement by aggregation.

Composition

Composition is a special case of aggregation that is a restricted aggregation is called


composition. If an object contains another object and contained object cannot be exist without
existence of container object.

It represents part-of relationship and in this both entities are depending on each other.
Generalization

It is a process of exacting shared characteristics from two or more classes and combining them
into generalized super class. Generalization is also called a “Is A Relationship”.

Associative

It is a relationship between two objects and it defines the multiplicity between objects.
One to One, Many to One, Many to Many, Many to One all these relationships are association
between objects.

Aggregation is a special form of association and composition is a special form of aggregation.

3. Design and build class diagrams using a UML tool (P2)


Use-case diagram
Flowchart diagram-Pseudo-code (at least 3 flowcharts for main features and explanations)

There are three flowcharts for most complex functions.

1. ADD function

This diagram is for entering students or lecturers information.

2. Update function
3. DELETE function
4. This diagram is for searching students or lecturers information.
Class diagram and explanation

A class called Students is designed as shown in the following class diagram. It contains:
• • stdId: The student ID (Example: GTxxxxx, GCxxxxx, etc.)
• • stdName: Student name.
• • stdDoB: Student date of birth.
• • stdEmail: Student email.
• • stdAddress: Student address.
• • stdBatch: The batch (class) of the student.
• • lecId: Lecturer ID.
• • lecName: Lecturer.
• • lecDoB: Lecturer date of birth.
• • lecEmail: Lecturer email.
• • lecAddress: Lecturer address.

-Judgments for features have been included/excluded and why certain features have been used
over

References
1. Subscription.packtpub.com. 2021. {{metadataController.pageTitle}}. [online] Available at:
<https://subscription.packtpub.com/book/application_development/9781786463593/1/ch01lv
l1sec13/object-oriented-paradigm> [Accessed 16 June 2021].

2. W3schools.com. 2021. C# Interface. [online] Available at:


<https://www.w3schools.com/cs/cs_interface.php> [Accessed 16 June 2021].

3. W3schools.com. 2021. C# Inheritance. [online] Available at:


<https://www.w3schools.com/cs/cs_inheritance.php> [Accessed 16 June 2021].

4. W3schools.com. 2021. C# Polymorphism. [online] Available at:


<https://www.w3schools.com/cs/cs_polymorphism.php> [Accessed 16 June 2021].

5. W3schools.com. 2021. C# Abstraction. [online] Available at:


<https://www.w3schools.com/cs/cs_abstract.php> [Accessed 16 June 2021].

6. W3schools.com. 2021. C# Classes and Objects. [online] Available at:


<https://www.w3schools.com/cs/cs_classes.php> [Accessed 16 June 2021].

7. Tutorials Link. 2021. Basic Characteristics of Oops. [online] Available at:


<https://tutorialslink.com/Articles/Basic-Characteristics-of-Oops/1308> [Accessed 16 June
2021].

8. PCMAG. 2021. Definition of object-oriented programming. [online] Available at:


<https://www.pcmag.com/encyclopedia/term/object-oriented-programming> [Accessed 16
June 2021].
9. dzone.com. 2021. When to Use Abstract Class and Interface - DZone Java. [online] Available at:
<https://dzone.com/articles/when-to-use-abstract-class-and-intreface> [Accessed 16 June
2021].

10. D.umn.edu. 2021. Object-Oriented Terminology. [online] Available at:


<https://www.d.umn.edu/~gshute/softeng/object-oriented.html> [Accessed 16 June 2021].

You might also like