Intro to Classes & Objects


 

State and Operations

In object-oriented programming, objects can represent actual objects in the real world, such as houses, students, fish, or clocks, or more abstract or computer-specific objects, such as lists, locations, or email messages.

                                               

 
 


 
 

Class
 
State
properties / attributes
(generally private)
 
Operations (or Actions)
methods / functions
(generally public)
color, owner, address paint(newColor), sellTo(newOwner), getColor(), getAddress()
size, color, location move(), getColor(), getLocation()

 
hour, minute, time zone set(hour, minute), changeTZ(newZone), getHour(), getMinute()
"Hello!" string contents length(), equals(anotherString), contains(aSubString)

 


 

Big Questions:

 


Alyce Brady, Kalamazoo College