Skip to content

Package: TicTacToePlayerImpl

TicTacToePlayerImpl

nameinstructionbranchcomplexitylinemethod
TicTacToePlayerImpl(String, boolean)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
TicTacToePlayerImpl(TicTacToePlayer)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
deepCopy()
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
equals(Object)
M: 2 C: 19
90%
M: 1 C: 5
83%
M: 1 C: 3
75%
M: 1 C: 3
75%
M: 0 C: 1
100%
hashCode()
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
isUsingCrosses()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
toString()
M: 31 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * Copyright © 2021 Fachhochschule für die Wirtschaft (FHDW) Hannover
3: *
4: * This file is part of ipspiel22-tictactoe-core.
5: *
6: * ipspiel22-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: * ipspiel22-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: * ipspiel22-tictactoe-core. If not, see <http://www.gnu.org/licenses/>.
18: */
19: package de.fhdw.gaming.ipspiel22.tictactoe.core.domain.impl;
20:
21: import de.fhdw.gaming.core.domain.AbstractPlayer;
22: import de.fhdw.gaming.ipspiel22.tictactoe.core.domain.TicTacToeFieldState;
23: import de.fhdw.gaming.ipspiel22.tictactoe.core.domain.TicTacToePlayer;
24:
25: /**
26: * Implements {@link TicTacToePlayer}.
27: */
28: final class TicTacToePlayerImpl extends AbstractPlayer<TicTacToePlayer> implements TicTacToePlayer {
29:
30: /**
31: * {@code true} if this player uses crosses, or {@code false} if she uses noughts.
32: */
33: private final boolean usingCrosses;
34:
35: /**
36: * Creates a Tic Tac Toe player.
37: *
38: * @param name The name of the player.
39: * @param usingCrosses {@code true} if this player uses crosses, or {@code false} if she uses noughts..
40: */
41: TicTacToePlayerImpl(final String name, final boolean usingCrosses) {
42: super(name);
43: this.usingCrosses = usingCrosses;
44: }
45:
46: /**
47: * Creates a Tic Tac Toe player.
48: *
49: * @param source The {@link TicTacToePlayer} to copy.
50: */
51: TicTacToePlayerImpl(final TicTacToePlayer source) {
52: super(source);
53: this.usingCrosses = source.isUsingCrosses();
54: }
55:
56: @Override
57: public String toString() {
58: return String.format(
59: "TicTacToePlayer[name=%s, type=%s, state=%s, outcome=%s]",
60: this.getName(),
61:• this.usingCrosses ? TicTacToeFieldState.CROSS.toString() : TicTacToeFieldState.NOUGHT.toString(),
62: this.getState(),
63: this.getOutcome());
64: }
65:
66: @Override
67: public boolean equals(final Object obj) {
68:• if (obj instanceof TicTacToePlayerImpl) {
69: final TicTacToePlayerImpl other = (TicTacToePlayerImpl) obj;
70:• return super.equals(obj) && this.usingCrosses == other.usingCrosses;
71: }
72: return false;
73: }
74:
75: @Override
76: public int hashCode() {
77: return super.hashCode() ^ Boolean.hashCode(this.usingCrosses);
78: }
79:
80: @Override
81: public boolean isUsingCrosses() {
82: return this.usingCrosses;
83: }
84:
85: @Override
86: public TicTacToePlayer deepCopy() {
87: return new TicTacToePlayerImpl(this);
88: }
89: }