Reference

Point(3poc)

Portable Object Compiler Point class

NAME

Point - Portable Object Compiler Point class

Point

Inherits from:

Object

Class Description

Point instances are implemented as pairs of two C integers. This is partly because of compatibility with the corresponding ICpak101 class, and partly because it (as opposed to some floating point arithmetic) gives portable results for equality testing.

Method types

Creation

* new
* x:y:

Instance Variables

* x:y:
* x:
* y:
* x
* y

Comparing

* hash
* isEqual:
* isBelow:
* isAbove:
* isLeft:
* isRight:

Point Arithmetic

* moveBy:
* moveBy::
* moveTo:
* plus:
* translateBy:

Printing

* printOn:
* fileOutOn:
* fileInFrom:

Methods

new

+ new

Returns the point (0,0).

x:y:

+ x :(int) x y :(int) y

Returns the point (x,y).

x:y:

- x :(int) x y :(int) y

Resets the coordinates of an existing point to (x,y).

x:

- x :(int) x

Resets the xLoc coordinate. Returns the receiver.

y:

- y :(int) y

Resets the yLoc coordinate. Returns the receiver.

x

- ( int ) x

Returns xLoc as int value.

y

- ( int ) y

Returns yLoc as int value.

hash

- ( unsigned ) hash

Returns a hash value based on the values of xLoc and yLoc .

isEqual:

- ( BOOL ) isEqual : aPoint

Returns YES if both arguments are instances of Point (or of a subclass of Point) and if they have the same coordinates.

isBelow:

- ( BOOL ) isBelow : aPoint

Returns YES if the receiver's y coordinate is greater than the y coordinate of aPoint .

isAbove:

- ( BOOL ) isAbove : aPoint

Returns YES if the receiver's y coordinate is less than the y coordinate of aPoint .

isLeft:

- ( BOOL ) isLeft : aPoint

Returns YES if the receiver's x coordinate is less than the x coordinate of aPoint .

isRight:

- ( BOOL ) isRight : aPoint

Returns YES if the receiver's x coordinate is greater than the x coordinate of aPoint .

moveBy:

- moveBy : aPoint

Adds coordinates of aPoint to the receiver. Unlike plus: , this method does not return a new object.

moveBy::

- moveBy :(int) x :(int) y

Adds x and y coordinates of aPoint to the receiver. Unlike plus: , this method does not return a new object.

moveTo:

- moveTo : aPoint

Copies the coordinates of aPoint into the receiver. Typically used for translation.

plus:

- plus : aPoint

This method is like moveBy: but it returns a new point instance.

translateBy:

- translateBy : aPoint

This method is like moveBy: but it returns a new point instance.

printOn:

- printOn :(IOD) aFile

Prints x and y coordinates inside parenthesis.

fileOutOn:

- fileOutOn : aFiler

Writes the point on aFiler . Returns the receiver.

fileInFrom:

- fileInFrom : aFiler

Reads the point from aFiler . Returns the receiver.