21
Object Oriented Programing Created By Oakvale Original Source By M(shape) Template PPT By http://www.templateswise.com Exceed Camp Project

Object Oriented Programing

Embed Size (px)

DESCRIPTION

Object Oriented Programing. Exceed Camp Project. Created By Oakvale Original Source By M( shape ) Template PPT By http://www.templateswise.com. Meaning & Concept Of OOP. OOP เป็นสไตล์การเขียนโปรแกรม OOP เป็นการมอง และแบ่งแยกโปรแกรมออกมาเป็นส่วนๆ เป็นชิ้นๆ. - PowerPoint PPT Presentation

Citation preview

Page 1: Object  Oriented Programing

Object Oriented Programing

Created By OakvaleOriginal Source By M(shape)

Template PPT By http://www.templateswise.com

Exceed Camp Project

Page 2: Object  Oriented Programing

Meaning & Concept Of OOP

• OOP เป็�นสไตล์การเขี�ยนโป็รแกรม• OOP เป็�นการมอง แล์ะแบ่�งแยก

โป็รแกรมออกมาเป็�นส�วนๆ เป็�นชิ้��นๆ

2

Page 3: Object  Oriented Programing

Meaning of Class & Object

• Classเป็�นต�นแบ่บ่ (blueprint) ในการสร�าง object

• Objectเป็�น instance of class

3

Class

PersonClass

Page 4: Object  Oriented Programing

Class ม�อะไรบ่�าง?

• attribute == ต วแป็ร• behavior == method

4

Class

PersonClass

Person Class

+ name : string + height : float + weight : float + age : int + sex : string

+ walkAhead() : void + turnLeft() : void + turnRight() : void

Page 5: Object  Oriented Programing

Object is instance of Class

5

Class

PersonClass

new Person() มา + name = “Honey” + height = 40.5 + weight = 25.2 + age =2 + sex = “female”

+ walkAhead() : void + turnLeft() : void + turnRight() : void

new Person() มา + name = “mint” + height = 173.4 + weight = 89 + age = 99 + sex = “male”

+ walkAhead() : void + turnLeft() : void + turnRight() : void

new Person() มา + name = “Oak” + height = 210.3 + weight = 55 + age =20 + sex = “male”

+ walkAhead() : void + turnLeft() : void + turnRight() : void

Person Class

+ name : string + height : float + weight : float + age : int + sex : string

+ walkAhead() : void + turnLeft() : void + turnRight() : void

Page 6: Object  Oriented Programing

Ready for Typing Person Class?

6

Class

PersonClass

Person Class + name : string + age : int + sex : string + height : float + weight : float + x : int + Person( name:string, age:int, sex:string ) : void + WalkAhead( distance:int ) : void + CanDrink() : bool + ToString() : string

Page 7: Object  Oriented Programing

Declare Attribute of Person Class

7

Class

PersonClass

Person Class + name : string + age : int + sex : string + height : float + weight : float + x : int + Person( name:string, age:int, sex:string ) : void

+ WalkAhead( distance:int ) : void

+ CanDrink() : bool

+ ToString() : string

Page 8: Object  Oriented Programing

Constructor of Person Class

8

Class

PersonClass

Person Class + name : string + age : int + sex : string + height : float + weight : float + x : int + Person( name:string, age:int, sex:string ) : void

+ WalkAhead( distance:int ) : void

+ CanDrink() : bool

+ ToString() : string

Page 9: Object  Oriented Programing

WalkAhead() Method

9

Class

PersonClass

Person Class + name : string + age : int + sex : string + height : float + weight : float + x : int + Person( name:string, age:int, sex:string ) : void

+ WalkAhead( distance:int ) : void

+ CanDrink() : bool

+ ToString() : string

Page 10: Object  Oriented Programing

CanDrink() Method

10

Class

PersonClass

Person Class + name : string + age : int + sex : string + height : float + weight : float + x : int + Person( name:string, age:int, sex:string ) : void

+ WalkAhead( distance:int ) : void

+ CanDrink() : bool

+ ToString() : string

Page 11: Object  Oriented Programing

ToString() Method

11

Class

PersonClass

Person Class + name : string + age : int + sex : string + height : float + weight : float + x : int + Person( name:string, age:int, sex:string ) : void

+ WalkAhead( distance:int ) : void

+ CanDrink() : bool

+ ToString() : string

Page 12: Object  Oriented Programing

Let’s Use Person Class

12

Class

PersonClass

Page 13: Object  Oriented Programing

<< OOP Pause >>

13

Page 14: Object  Oriented Programing

Primitive VS Reference

• int, float, double, char, sting is Primitive. • แล์�วอะไรที่�"ไม�ใชิ้� Primitive Data Type??

• Array เป็�น Primitive Data Type?• Class ที่�"เราเขี�ยนเอง เป็�น type ไหนอ�ะ??

• Reference == Data Type ที่�"อ�างอ�งต$าแหน�งที่�"ในหน�วยความจำ$า

14

Data type

Data type

Data type

Page 15: Object  Oriented Programing

In Memory

In Memory

In Memory

b = 3a = 3

What’s difference BetweenPrimitive VS Reference

15

Data type

Data type

int a=5;int b=3;

a=b;

int a=5;int b=3;

a=b;

Circle a= new Circle( 5 );Circle b= new Circle( 3 );

a=b;

Circle a= new Circle( 5 );Circle b= new Circle( 3 );

a=b;

In Memory

5

3a = 5 a

b

Page 16: Object  Oriented Programing

About Attribute

Access Modifier– private เห'นได้�เฉพาะใน class เที่�าน �น– public ที่+กคนเร�ยกใชิ้�ได้�

16

Page 17: Object  Oriented Programing

<< OOP Continue >>

17

Page 18: Object  Oriented Programing

UML

• Unified Modeling LanguageUML ถู-กใชิ้�ในการส."อสารก นภายในที่�ม เพ."อให�เขี�าใจำตรงก น รวมถู0งชิ้�วยในการ แบ่�งงาน แบ่�งส�วน ขีองโป็รแกรม

18Resource Form http://www.thaiall.com/uml/indexo.html

Page 19: Object  Oriented Programing

Many Type of UML

19Resource Form http://www.thaiall.com/uml/indexo.html

Page 20: Object  Oriented Programing

Sample UML Class Diagram

20Resource Form http://www.thaiall.com/uml/indexo.html

Page 21: Object  Oriented Programing

May the Force be with YOU.

21

Thanks, your watching.

…^( ^ ^ )^...