18.10.2014 Views

Object-oriented Software in Ada 95

Object-oriented Software in Ada 95

Object-oriented Software in Ada 95

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Preface<br />

xvii<br />

Class attribute<br />

A data component that is shared between all objects <strong>in</strong> the class. In effect it is<br />

a global variable which can only be accessed by methods <strong>in</strong> the class. A class<br />

attribute is declared <strong>in</strong> the private part of the package represent<strong>in</strong>g the class.<br />

For example, the class attribute The_Interest_Rate <strong>in</strong> the class<br />

Interest_Account is declared <strong>in</strong> the private part of the package as<br />

follows:<br />

package Class_Interest_Account is<br />

type Interest_Account is private;<br />

procedure Set_Rate( Rate:<strong>in</strong> Float );<br />

private<br />

type Interest_Account is new Account with record<br />

Balance_Of : Money := 0.00;<br />

Accumulated_Interest : Money := 0.00;<br />

end record;<br />

The_Interest_Rate : Float := 0.00026116;<br />

end Class_Interest_Account;<br />

Class method<br />

A procedure or function <strong>in</strong> a class that only accesses class attributes. For<br />

example, the method Set_Rate <strong>in</strong> the class Interest_Account which<br />

sets the class attribute The_Interest_Rate is as follows:<br />

procedure Set_Rate( Rate:<strong>in</strong> Float ) is<br />

beg<strong>in</strong><br />

The_Interest_Rate := Rate;<br />

end Set_Rate;<br />

Note: As Set_Rate is a class method an <strong>in</strong>stance of the class is not<br />

passed to the procedure.<br />

Controlled<br />

object<br />

Discrim<strong>in</strong>ant<br />

An object which has <strong>in</strong>itialization, f<strong>in</strong>alization and adjust actions def<strong>in</strong>ed. A<br />

limited controlled object only has <strong>in</strong>itialization and f<strong>in</strong>alization def<strong>in</strong>ed as<br />

assignment is prohibited.<br />

The declaration of an object may be parameterized with a value. The value is<br />

a discrim<strong>in</strong>ant to the type. For example, the declaration of cor<strong>in</strong>na is<br />

parameterized with the length of her name.<br />

type Person( Chs:Str_Range := 0 ) is record<br />

Name : Str<strong>in</strong>g( 1 .. Chs );<br />

Height : Height_Cm := 0;<br />

Sex : Gender;<br />

end record;<br />

Cor<strong>in</strong>na : Person(7);<br />

Dynamicb<strong>in</strong>d<strong>in</strong>g<br />

The b<strong>in</strong>d<strong>in</strong>g between an object and the message that is sent to it is not known<br />

at compile-time.<br />

© M A Smith - May not be reproduced without permission

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!