Escolar Documentos
Profissional Documentos
Cultura Documentos
Chapter 1.
lass and Object are the most basic and important concepts to understand and
develop Object-Oriented Programs.
Class
Class is a template that defines the type of an object. It contains common
traits and behaviors for multiple objects. Lets say that you are developing
video store management program, then you will need to allow it to create new
customer which is an object at programming level. What are the common
traits and behaviors that the program should store for each customer in
relation to video shop? Traits would be name, phone number rental video and
address which are attributes and behaviors would be renting and returning
videos which are methods. In other words, those common traits and behaviors
are declared in a class through which multiple customers can be created with
different values for attributes and methods.
Object
As I have mentioned above, objects in Object-Oriented programming refer to real
world entity such as a book, person, a car and so on. These objects consist of two
factors which are state and operations. The state represents the actual values for
attributes.
Then the operations declare the actions that objects can do in a program. For
example, customer objects in the video management program can rent videos by
executing Rent method.
[ Picture 3 ] Method
These objects are also called Instance of a class, and creating objects through a
class is often called instantiate objects from a class.