View
56
Download
6
Category
Preview:
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
Object Oriented Programing
Created By OakvaleOriginal Source By M(shape)
Template PPT By http://www.templateswise.com
Exceed Camp Project
Meaning & Concept Of OOP
• OOP เป็�นสไตล์การเขี�ยนโป็รแกรม• OOP เป็�นการมอง แล์ะแบ่�งแยก
โป็รแกรมออกมาเป็�นส�วนๆ เป็�นชิ้��นๆ
2
Meaning of Class & Object
• Classเป็�นต�นแบ่บ่ (blueprint) ในการสร�าง object
• Objectเป็�น instance of class
3
Class
PersonClass
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
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
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
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
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
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
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
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
Let’s Use Person Class
12
Class
PersonClass
<< OOP Pause >>
13
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
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
About Attribute
Access Modifier– private เห'นได้�เฉพาะใน class เที่�าน �น– public ที่+กคนเร�ยกใชิ้�ได้�
16
<< OOP Continue >>
17
UML
• Unified Modeling LanguageUML ถู-กใชิ้�ในการส."อสารก นภายในที่�ม เพ."อให�เขี�าใจำตรงก น รวมถู0งชิ้�วยในการ แบ่�งงาน แบ่�งส�วน ขีองโป็รแกรม
18Resource Form http://www.thaiall.com/uml/indexo.html
Many Type of UML
19Resource Form http://www.thaiall.com/uml/indexo.html
Sample UML Class Diagram
20Resource Form http://www.thaiall.com/uml/indexo.html
May the Force be with YOU.
21
Thanks, your watching.
…^( ^ ^ )^...
Recommended