際際滷

際際滷Share a Scribd company logo
Classes and Objects
Paul Inventado
De La Salle University
Abstraction
 Hiding information and implementation
through specialized entities
Color: White
Size: 2.5x1.5 in
on() - ...
off() - ...
Color: White
Memory: 4GB
# of Songs: 594
play() - ...
pause() - ...
stop() - ...
Color: White
Memory: 120GB
Processor: Core 2 Duo
Graphics: Nvidia 128MB
boot() - ...
playMovie() - ...
shutdown() - ...
Advantages of Abstraction
 Less complex view of the system
 No need to worry about the implementation
of another entity
 Other entities are assumed to work
Advantages of Abstraction
Abstract Data Types
 data structure
 contains single or multiple information
 contains a set of operations
 may be defined by a programmer (user
defined data type)
Classes
 actual representation of abstract data types
in OOP
 contains attributes and methods
 attributes  properties of the class
 methods  operations of the class
 serves as a blue print for objects
Classes
Person
name
gender
height
weight
getName()
getGender()
getHeight()
getWeight()
say(String text)
walk(int X, int Y)
Objects
 instance of a class (follows the blue print
provided by the class)
 uniquely identified by a name (identifier)
 has a state and behavior
 state  status of the attributes
 behavior  use of the methods
Classes and Objects
Person
name
gender
height
weight
getName()
getGender()
getHeight()
getWeight()
say(String text)
walk(int X, int Y)
Name: Bruce Wayne
Gender: Male
Height: 6'2
Weight: 210 lbs
getName()
say(String text)
walk(int X, int Y)
...
Name: Joker
Gender: Male
Height: 6'5
Weight: 191 lbs
getName()
say(String text)
walk(int X, int Y)
...
Name: Harvey Dent
Gender: Male
Height: 6'0
Weight: 182 lbs
getName()
say(String text)
walk(int X, int Y)
...
Classes and Objects
1)Identify the classes and the objects from the list below
2)Categorize the objects that are instances of a class
Wonder Woman UP
UST GloriaArroyo
Superhero DLSU
A1 Spiderman
President GeorgeBush
Batman Backstreet Boys
BoyBand University
Classes and Objects
Paul Inventado
De La Salle University

More Related Content

Classes and objects