package gdi1sokoban.globals;
/**
* class to store a point on the map
*/
// top and left position of point
public int top, left;
/**
* constructor for given position
* @param top top position of point
* @param left left position of point
*/
public Point(final int top,
final int left
){
this.top = top;
this.left = left;
}
/**
* constructor for given point
* @param p point
*/
this.top = p.top;
this.left = p.left;
}
/**
* returns a new point
* containing the position of the right, left, up, or down field
* of this point
* @param dir direction in {R, U, L, D}-format
*/
public Point moveDirection
(final char dir
){
switch(dir){
case 'U':
return new Point(top-
1, left
);
case 'R':
return new Point(top, left+
1);
case 'D':
return new Point(top+
1, left
);
case 'L':
return new Point(top, left-
1);
}
// invalid direction-char
return new Point(top, left
);
}
/**
* get Point as String
* @return point as string format: {top, left}
*/
return "{"+top+","+left+"}";
}
}