From 295ecd2bb157c98302db2ff84add0fb9354dfb57 Mon Sep 17 00:00:00 2001 From: Max Wenzel Date: Wed, 12 Jan 2022 13:16:55 +0100 Subject: [PATCH] add DeafaultState(EMPTY) to Coordinate --- .../java/de/tims/fleetstorm/matchfield/Coordinate.java | 10 ++++++++++ .../de/tims/fleetstorm/matchfield/CoordinateTest.java | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/src/main/java/de/tims/fleetstorm/matchfield/Coordinate.java b/src/main/java/de/tims/fleetstorm/matchfield/Coordinate.java index a084376..dcace9e 100644 --- a/src/main/java/de/tims/fleetstorm/matchfield/Coordinate.java +++ b/src/main/java/de/tims/fleetstorm/matchfield/Coordinate.java @@ -3,10 +3,17 @@ package de.tims.fleetstorm.matchfield; public class Coordinate { private int x; private int y; + private int state; + + public static final int EMPTY = 0; + public static final int SHIP = 1; + public static final int SHOT = 2; + public static final int HIT = 3; public Coordinate(int x, int y) { this.x = x; this.y = y; + this.state = 0; } public Integer getX() { @@ -17,4 +24,7 @@ public class Coordinate { return y; } + public int getState() { + return this.state; + } } diff --git a/src/test/java/de/tims/fleetstorm/matchfield/CoordinateTest.java b/src/test/java/de/tims/fleetstorm/matchfield/CoordinateTest.java index 75b87af..d37a398 100644 --- a/src/test/java/de/tims/fleetstorm/matchfield/CoordinateTest.java +++ b/src/test/java/de/tims/fleetstorm/matchfield/CoordinateTest.java @@ -17,4 +17,9 @@ class CoordinateTest { assertEquals(coordinate.getY(), y); } + @Test + void testCoordinatehasDefaultStates() { + assertEquals(coordinate.getState(), Coordinate.EMPTY); + assertEquals(coordinate.getState(), 0); + } }