domingo, 24 de noviembre de 2013

We have made a first foray into Java but it is essential we continue talking about fundamental concepts of OOP: objects and classes. These terms seem familiar resultarnos.
 
In daily life we can think of objects as an apple or a book and we can distinguish kinds of things such kinds of plants . However, the term programming and the term object class does not keep an exact correlation with the meaning of these words in everyday life . We can find some similarities and even make didactic analogies. But always try to find equivalences between objects and classes in programming classes and objects of daily life because that exact match does not exist and will lead to confusion. When writing a program in an object-oriented language we try to model a real-world problem thinking of objects that are part of the problem and are interrelated . We now give a first definition of object and class, we have to go as we move into the qualifying course .

RE: existing entity in the computer memory that has properties ( attributes or data itself stored by the object) and a specific available operations ( methods).

Class: abstraction that defines a type of object specifying which properties ( attributes) and operations will be available .


superclass            clases                     object


                                                    Taxi enrollment  PLO-6589
vehicle     {   taxi       {      Taxi enrollment  MDE-8576
                                                    Taxi enrollment   FRS-4692



In this example we have considered the problem consists of three vehicle types : taxi, bus and tram , and those guys call them classes. What would we do in Java to define a class ? Display its properties and operations ( methods) available, for example :

Class Taxi {

properties:

identifying Registration

District in which it operates

Type diesel or gasoline engine

Coordinates at which is located

 Available operations :

                                                Assign an enrollment

                                                Assign a district

                                                Assign an engine type

                                                Locate on coordinates

}


Having thus defined the cab mean that every object type Taxi we believe will have an identification plate , a district in which it operates , a type of motor and coordinates in which it is located. The creation of an object would be something like : "Creating an object with tuition Taxi BFG- 7452 , North district , type of Diesel engine and coordinates Unknown . "

The use of an operation on an object would be something like : "Taxi BFG- 7452 -> Locate coordinates (X = 128223 , Y = 877533 ) " . The operations are called methods in Java , see how they are defined below.

We say that an object is an instance of a class . For example the taxi registration BFG- 7452 is an instance of the class Taxi . Several objects (eg taxis) of the same class say are multiple instances of the class . We shall see that both a class and an object in Java can represent things other than what we have now explained, but all in good time .


0 comentarios:

Publicar un comentario

deja un comentario