Commit ccb95be9 authored by Pony's avatar Pony

Change precondition in point

parent 41c56b09
......@@ -279,9 +279,23 @@ public class Point extends Float {
* @pre point.state equal to state iff point != null
*/
public Point add(@Nullable Point point) {
if (point == null)
if (point == null) {
return this;
Preconditions.checkArgument(point.getState().getClass().getName().equals(state.getClass().getName()));
}
switch (state.getClass().getSimpleName()) {
case "TableCoordinates":
point.toTableCoordinates();
break;
case "ScreenCoordinates":
point.toScreenCoordinates();
break;
case "CameraCoordinates":
point.toCameraCoordinates();
break;
default:
System.err.println("This should never happen! State: " + state.toString());
break;
}
Point clone = clone();
clone.setLocation(clone.x + point.x, clone.y + point.y);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment