Size Class

A Size object encapsulates a width and height dimension in a 2-D coordinate system.

Requires:

The Size class requires the class definition file oodPlain.cls:

::requires "oodPlain.cls"

Methods:

Instances of the Size class implement the methods listed in the following table:

Table 10-5. Size Class and Instance Methods

Method......on page
new (Class Method)new
widthwidth
width=width=
heightheight
height=height=

new (Class Method)

               +-0-----+     +-width---+
>>-.Size~new(--+-------+--,--+---------+--)----------------><
               +-width-+     +-height--+

Instantiates a new Size object with the dimensions specified.

Arguments:

The arguments are:

width

The whole number value of the width of the new object. The defualt is 0.

height

The whole number value of the height for the new object. The default is the width value.

Return value:

This method returns the new Size object.

Example:


size = .Size~new(4, 8)
say 'Width:' size~width 'Height:' size~height
say
size2 = .Size~new(16)
say 'A new size object:'
say '  Width: ' size2~width
say '  Height:' size2~height
say

size2~width = 100
size2~height = 300
say 'New width:' size2~width 'new height:' size2~height
say

::requires 'oodPlain.cls'

/* Output would be:

Width: 4 Height: 8

A new size object:
  Width:  16
  Height: 16

New width: 100 new height: 300

*/

width

>>-aSize~width---------------------------------------------><

Retrieves the width of the size object.

Arguments:

This method takes no arguments

Return value:

The return value is the width of the object

Example:

See .Size~new example.

width=

>>-aSize~width=value---------------------------------------><

Sets the width of the size object.

Arguments:

This method has one argument:

value

The new width of the size object.

Return value:

This method does not return a value.

Example:

See .Size~new example.

height

>>-aSize~height--------------------------------------------><

Retrieves the height of the size object.

Arguments:

This method takes no arguments

Return value:

Returns the height of the size object.

Example:

See .Size~new example.

height=

>>-aSize~height=value--------------------------------------><

Sets the height of the size object.

Arguments:

This method has one argument:

value

The new height of the size object.

Return value:

This method does not return a value.

Example:

See .Size~new example.