Class Position

Position represents a coordinate in 2 dimensional x/y space. The values of x and y may be any integers.

CONSTRUCTION

COMPARISION

OTHER METHODS

Example

main
  position p1 = 0, 0
  position p2 = -10, 50
  position p3 = 680, 1245
            

(position) <position sourcePosition>.copy

Creates a new position that is an exact copy of sourcePositionn.

Parameters

Return value

Example

main
  position p1 = 0, 0
  position p2 = p1.copy     // p2 == 0,0
            

(position) <int x>, <int y>

Creates a new position with the given x and y values.

Parameters

Return value

Example

main
  position p = 120, 360     // p == 120, 360
            

(bool) <position p1> == <position p2>

Comparision

Parameters

Return value

Example

main
  position p1 = 120, 360
  position p2 = 360, 120
  bool samePosition = p1 == p2  // samePosition == false
            

(bool) <position p1> != <position p2>

Comparision

Parameters

Return value

Example

main
  position p1 = 120, 360
  position p2 = 360, 120
  bool samePosition = p1 != p2  // samePosition == true
            

(int) get x

Get the value of the x-coordinate.

Return value

Example

main
  position p = 120, 360
  int x = p.get x           // x == 120
            

(int) get y

Get the value of the y-coordinate.

Return value

Example

main
  position p = 120, 360
  int y = p.get y           // x == 360
            

set x to <int newX>

Assing a new value for the x-coordinate.

Parameters

Example

main
  position p = 120, 360
  p.set x to 360           // p == 360, 360
            

set y to <int newY>

Assing a new value for the y-coordinate.

Parameters

Example

main
  position p = 120, 360
  p.set y to 120           // p == 120, 120