Point Class

The Point class represents a point in a 2-D coordinate system.

Requires:

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

::requires "oodPlain.cls"

Methods:

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

Table 10-4. Point Class and Instance Methods

Method......on page
new (Class Method)new
xx
x=x=
yy
y=y=

new (Class Method)

                +-0-+     +-x-+
>>-.Point~new(--+---+--,--+---+--)-------------------------><
                +-x-+     +-y-+

Arguments:

The arguments are:

x

The x coordinate of the point. The default is 0.

y

The y coordinate of the point. The default is the x coordinate.

Return value:

This method returns a new Point object.

Example:

p = .Point~new(45, 90)
say 'Point p is at ('p~x','p~y')'
say
q = .Point~new(55)
say 'A new point q is at ('q~x','q~y')'
say

q~x = 150
q~y = 300
say 'Changed point q to be at ('q~x','q~y')'
say

::requires 'oodPlain.cls'

/* Output would be:

Point p is at (45,90)

A new point q is at (55,55)

Changed point q to be at (150,300)

*/

x

>>-aPoint~x------------------------------------------------><

Retrieves the x coordinate of the point.

Arguments:

This method takes no arguments

Return value:

The return value is the x coordinate.

Example:

See .Point~new example.

x=

>>-aPoint~x=value------------------------------------------><

Sets the x coordinate of the point

Arguments:

This method has one argument:

value

The new x coordinate for the point.

Return value:

This method does not return a value.

Example:

See .Point~new example.

y

>>-aPoint~y------------------------------------------------><

Retrieves the y coordinate of the point.

Arguments:

This method takes no arguments

Return value:

The return value is the y coordinate of the point.

Example:

See .Point~new example.

y=

>>-aPoint~y=value------------------------------------------><

Sets the y coordinate of the point

Arguments:

This method has one argument:

value

The new y coordinate for the point.

Return value:

This method does not return a value.

Example:

See .Point~new example.