Professional Documents
Culture Documents
AS1 - HUỲNH NHẬT NAM - GCS190293 - GCS0805B
AS1 - HUỲNH NHẬT NAM - GCS190293 - GCS0805B
ASSIGNMENT
No.1
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
In this assignment, you will have opportunities to provide evidence against the following
criteria.
Indicate the page numbers where the evidence can be found.
- Object/Class,
P1. Discuss the - Abstraction,
principles;
characteristics - Encapsulation,
and - Inheritance, 1
features of object
orientated - Polymorphism,
programming. - Abstract classes,
- Interfaces
Summative feedback:
Assessor’s Date:
Signature:
ASSIGNMENT 1 BRIEF
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.
1. Manage Students
2. Manage Lecturers
3. Exit
=======================
Please choose:
When user selects 1, the program will display submenu for managing
students:
=======================
=======================
Please choose:
When user selects 2, the program will display submenu for managing
lecturers:
=======================
=======================
Please choose:
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 ‘|’.
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.
Submission
Students are expected to submit hard copy of assignment
requirements
Grade Descriptor
PASS criteria
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.
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.
Characteristics of Oop’s
OOPs ( Object-oriented programming system ) has many Characteristics like:
• Class
• Objects
• Data Abstraction
• Data Encapsulation
• Inheritance
• Polymorphism
1.1. Object/Class
What is an object?
Example
Create an object called "myObj" and use it to print the value of color:
class Car
{
string color = "red";
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() {
}
}
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.
•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)
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
Console.WriteLine("Tuut, tuut!");
}
class Program
// 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
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.):
{
Console.WriteLine("The dog says: bow wow");
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
class Program
myPig.animalSound();
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.
Composition
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.
1. ADD function
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].