Skip to content

Package: TicTacToeBoard

TicTacToeBoard

Coverage

1: /*
2: * Copyright © 2021 Fachhochschule für die Wirtschaft (FHDW) Hannover
3: *
4: * This file is part of ipspiel23-tictactoe-core.
5: *
6: * ipspiel23-tictactoe-core is free software: you can redistribute it and/or modify it under
7: * the terms of the GNU General Public License as published by the Free Software
8: * Foundation, either version 3 of the License, or (at your option) any later
9: * version.
10: *
11: * ipspiel23-tictactoe-core is distributed in the hope that it will be useful, but WITHOUT
12: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14: * details.
15: *
16: * You should have received a copy of the GNU General Public License along with
17: * ipspiel23-tictactoe-core. If not, see <http://www.gnu.org/licenses/>.
18: */
19: package de.fhdw.gaming.ipspiel23.tictactoe.core.domain;
20:
21: import java.util.List;
22: import java.util.Map;
23: import java.util.Set;
24:
25: import de.fhdw.gaming.core.domain.Stateful;
26:
27: /**
28: * Represents the Tic Tac Toe board.
29: * <p>
30: * A Tic Tac Toe board is a square and hence possesses an identical non-zero positive number of rows and columns. Each
31: * combination of a row and a column is described by a {@link TicTacToePosition position}. At each position, there is a
32: * {@link TicTacToeField field} which describes whether the field is empty or marked by a cross or nought.
33: */
34: public interface TicTacToeBoard extends Stateful {
35:
36: /**
37: * Returns the number of rows (or columns) of this board.
38: */
39: int getSize();
40:
41: /**
42: * Checks whether this board contains a field at the position passed.
43: *
44: * @param position The position.
45: * @return {@code true} if this board contains a field at the position passed, else {@code false}.
46: */
47: boolean hasFieldAt(TicTacToePosition position);
48:
49: /**
50: * Returns the field at the given position.
51: *
52: * @param position The position of the field to return.
53: * @return The field.
54: * @throws IllegalArgumentException if the position is out of range, i.e. if it does not denote a field.
55: */
56: TicTacToeField getFieldAt(TicTacToePosition position);
57:
58: /**
59: * Returns all fields of this board line by line.
60: * <p>
61: * The list(s) returned are possibly immutable, so do not modify them.
62: */
63: List<List<? extends TicTacToeField>> getFields();
64:
65: /**
66: * Returns all fields of a given state.
67: * <p>
68: * The map returned returned is possibly immutable, so do not modify it.
69: *
70: * @param fieldState The state of the fields to return.
71: * @return The fields.
72: */
73: Map<TicTacToePosition, ? extends TicTacToeField> getFieldsBeing(TicTacToeFieldState fieldState);
74:
75: /**
76: * Returns all uniformly marked rows on the board. Empty rows are not returned.
77: * <p>
78: * The set returned returned is possibly immutable, so do not modify it.
79: */
80: Set<TicTacToeRow> getRowsUniformlyMarked();
81:
82: @Override
83: TicTacToeBoard deepCopy();
84: }