de.htwdd.rosenkoenig.game
Class Position

java.lang.Object
  extended by de.htwdd.rosenkoenig.game.Position

public class Position
extends java.lang.Object

This class wraps a position for the game. A position can be two things: either an x-y-position or an offset in x-y-direction. Either way, two values, thus only one class.


Field Summary
private  int x
           
private  int y
           
 
Constructor Summary
Position(int x, int y)
          Ctor, set x and y distance
 
Method Summary
 Position add(Position pos)
          Calculate a new position depending on this object and another position.
 int getX()
          Getter of the property x
 int getY()
          Getter of the property y
 boolean isOnBoard()
          Check if this position is on the game board.
 void setX(int x)
          Setter of the property x
 void setY(int y)
          Setter of the property y
 java.lang.String toString()
          Output the value of Position in a human readable fashion.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

private int x

y

private int y
Constructor Detail

Position

public Position(int x,
                int y)
Ctor, set x and y distance

Parameters:
x - distance x
y - distance y
Method Detail

getX

public int getX()
Getter of the property x

Returns:
Returns the x.

setX

public void setX(int x)
Setter of the property x

Parameters:
x - The x to set.

getY

public int getY()
Getter of the property y

Returns:
Returns the y.

setY

public void setY(int y)
Setter of the property y

Parameters:
y - The y to set.

toString

public java.lang.String toString()
Output the value of Position in a human readable fashion.

Overrides:
toString in class java.lang.Object

add

public Position add(Position pos)
Calculate a new position depending on this object and another position. Useful for calulating the position of a new stone starting from the current crown position when a card is played.

Parameters:
pos - offset to object's position
Returns:
new position

isOnBoard

public boolean isOnBoard()
Check if this position is on the game board.

Returns:
true, if stone is on board - false otherwise.