mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-01-19 02:36:14 +01:00
getPosition()
This commit is contained in:
parent
0ff5fceae7
commit
91b24db6ca
@ -7,14 +7,15 @@
|
|||||||
|
|
||||||
package pp.battleship.model;
|
package pp.battleship.model;
|
||||||
|
|
||||||
import com.jme3.network.serializing.Serializable;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import static java.lang.Math.max;
|
import static java.lang.Math.max;
|
||||||
import static java.lang.Math.min;
|
import static java.lang.Math.min;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.jme3.network.serializing.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a battleship in the game. A battleship is characterized by its length, position,
|
* Represents a battleship in the game. A battleship is characterized by its length, position,
|
||||||
@ -321,4 +322,14 @@ public class Battleship implements Item {
|
|||||||
public void accept(VoidVisitor visitor) {
|
public void accept(VoidVisitor visitor) {
|
||||||
visitor.visit(this);
|
visitor.visit(this);
|
||||||
}
|
}
|
||||||
|
public List<IntPoint> getPositions() {
|
||||||
|
List<IntPoint> positions = new ArrayList<>();
|
||||||
|
for (int x = getMinX(); x <= getMaxX(); x++) {
|
||||||
|
for (int y = getMinY(); y <= getMaxY(); y++) {
|
||||||
|
positions.add(new IntPoint(x, y));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return positions;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user