adjusted all constuctors of nodes so that if someone creates a node the piece will be null and the option for a constuctor without arguments is still given for serialization purposes

This commit is contained in:
Hanno Fleischer
2024-12-03 17:56:39 +01:00
parent 69865bb504
commit 81cb2f33ff
5 changed files with 10 additions and 4 deletions

View File

@@ -29,7 +29,7 @@ public Board() {
} else if (i == 4 || i == 14 || i == 24 || i == 34) { } else if (i == 4 || i == 14 || i == 24 || i == 34) {
infield[i] = new BonusNode(); infield[i] = new BonusNode();
} else { } else {
infield[i] = new Node(); infield[i] = new Node(null);
} }
} }
} }

View File

@@ -8,6 +8,6 @@
@Serializable @Serializable
public class BonusNode extends Node { public class BonusNode extends Node {
BonusNode(){ BonusNode(){
super(); super(null);
} }
} }

View File

@@ -8,6 +8,6 @@
@Serializable @Serializable
public class HomeNode extends Node { public class HomeNode extends Node {
public HomeNode() { public HomeNode() {
super(); super(null);
} }
} }

View File

@@ -9,7 +9,11 @@
public class Node { public class Node {
protected Piece occupant; protected Piece occupant;
public Node(){ public Node(Piece piece){
occupant = piece;
}
private Node(){
occupant = new Piece(Color.AIRFORCE, PieceState.WAITING); occupant = new Piece(Color.AIRFORCE, PieceState.WAITING);
} }

View File

@@ -18,10 +18,12 @@ public class StartNode extends Node {
* @param color the color of the node * @param color the color of the node
*/ */
public StartNode(Color color) { public StartNode(Color color) {
super(null);
this.color = color; this.color = color;
} }
private StartNode() { private StartNode() {
super(null);
color = Color.NONE; color = Color.NONE;
} }