Sunteți pe pagina 1din 4

16 OBJECT ORIENTED PROGRAMMING

LAB 1: INTRODUCTION TO OOP


LEARNING OUTCOMES
By the end of this lab, students should be able to :
1. Define OOP

THEORY

Classes, Object, Encapsulation, Data Abstraction, Inheritance and Polymorphism is


a basic terminologies in Object Oriented programming

Encapsulation: is a process of tying

Data abstraction: is a process to

together all data and methods that

delete all unnecessary attributes and

form a class and control the access to

remain the necessary attributes to

data by hiding its information.

describe an object.

4 Main concepts of
OOP

Polymorphism: Polymorphism is

Inheritance: Create a new class from

processes of giving the same message to

an existing class together with new

another two or more different objects

attributes and behaviors.

and produce different behaviors depend


on how the objects receive the message.

16 OBJECT ORIENTED PROGRAMMING

ACTIVITY 1
Procedure:
Look at the output from application below.The applicaion can accept the data given by
the user (name, regs. No, course and mark), then there are other functions to calculate
the gred depend on the mark. At last the information will display like below :

Name:
Regs. Number :
Course :
Mark:
Gred:

Jose dela Cruz


01DIT07F2345
Object Oriented Programming
80
A

Object

: Student

Data

: Name, Regs. Number, Course, Mark

Method : Accept()
Calculate()
Display()

16 OBJECT ORIENTED PROGRAMMING

EXERCISE
1.

Table below show all the information about staff in Guiuan Shopping Center.

Staff_No

Name

Gender

IC NO

Address

Telephone.No

Start
Working(Year)

A0410

Joey De Leon

750514-02-5843

No.1 Jalan
Batu
Berendam,
Melaka

014-2233678

2000

A8092

Vic Sotto

681223-03-5777

PT 32, Jalan
Kemaman,
Kuala Lumpur

0135678999

1994

Create an application to accept all the data as show in the information above. Other
than that, there are other functions to calculate the total years working and display all
the information like:
Name:
Joey De Leon
Start Working: 2000
Total year:
9

2.

Using data abstraction, take out all the data and functions that are needed to create this
application.
Object

: ____________________

Data

: ________________________________________________________

Method : ____________________
____________________
____________________

16 OBJECT ORIENTED PROGRAMMING


3.

Use the data encapsulation concept to gather all the data and appropriate functions into the
class.

______________________
{
__________________
__________________
__________________
__________________
__________________
__________________
__________________
Public:
_______________ ( );
_______________( );
_______________ ( );
};

NOTES
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________

S-ar putea să vă placă și