11package bwapi ;
22
3- class Point implements Comparable <Point >{
3+ public abstract class Point < T extends Point > implements Comparable <Point >{
44 static final int TILE_WALK_FACTOR = 4 ; // 32 / 8
55
66 public final int x ;
77 public final int y ;
88 private final int scalar ;
99
10- Point (final int x , final int y , final int type ) {
10+ protected Point (final int x , final int y , final int type ) {
1111 this .x = x ;
1212 this .y = y ;
1313 this .scalar = type ;
@@ -29,9 +29,9 @@ public String toString() {
2929 return "[" + x + ", " + y + "]" ;
3030 }
3131
32- protected double getDistance (final int x , final int y ) {
33- final int dx = x - this .x ;
34- final int dy = y - this .y ;
32+ public double getDistance (T point ) {
33+ final int dx = point . x - this .x ;
34+ final int dy = point . y - this .y ;
3535 return Math .sqrt (dx * dx + dy * dy );
3636 }
3737
@@ -52,10 +52,17 @@ private static int getApproxDistance(final int x1, final int y1, final int x2, f
5252 return (minCalc >> 5 ) + minCalc + max - (max >> 4 ) - (max >> 6 );
5353 }
5454
55- public int getApproxDistance (final Point point ) {
55+ public int getApproxDistance (final T point ) {
5656 return getApproxDistance (x , y , point .x , point .y );
5757 }
5858
59+ public abstract T subtract (T other );
60+
61+ public abstract T add (T other );
62+
63+ public abstract T divide (int divisor );
64+
65+ public abstract T multiply (int multiplier );
5966
6067 @ Override
6168 public boolean equals (Object o ) {
0 commit comments