Friday, December 30, 2016

Class (Basic concept of OOAD)

A class represents a collection of objects having same characteristics properties that exhibit common behavior. It gives the blue print or description of an object that can be created from it. creation of an object is an instance of a class.

The constitution of a class are:
  • A set of attributes for the object that are to be instantiated from the class. Generally different objects of a class have some difference in values of the attributes . attributes are often refereed as a class data.
  • A set of operations that shows the behavior of the objects of the class. operations are also refereed as functions or methods.


    Let us consider a simple class, circle that represents the geometrical figure circle in 2 dimensional space.
The attributes of this class can be x= x-coordinate of center, y=y-coordinate of a center, r=radius of the circle.

some of its operations can be defined as findArea(): method to calculate area.
scale(): method to increase or decrease the radius.

During Instant-ion, values are assigned for at least some of the attributes.
if we create an object my_circle, we can assign values like x=2,y=3 and r=4, to depict its state .
now if the operation scale() is performed on my_cycle with a scaling factor 2 , the value of r will become 8. 
This operation brings a change in the state of my_cycle. ie,the object has exhibited certain behavior.
 

No comments:

Mobile Cloud Computing

Cloud Computing offers such smartphones that have rich Internet media support, require less processing and consume less power. In terms of ...