Skip to content

Package: TicTacToePlayerBuilderImpl

TicTacToePlayerBuilderImpl

nameinstructionbranchcomplexitylinemethod
TicTacToePlayerBuilderImpl()
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
build()
M: 0 C: 10
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
changeName(String)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
changeUsingCrosses(boolean)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
isUsingCrosses()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 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 java.util.Optional;
22:
23: import de.fhdw.gaming.core.domain.GameException;
24: import de.fhdw.gaming.ipspiel22.tictactoe.core.domain.TicTacToePlayer;
25: import de.fhdw.gaming.ipspiel22.tictactoe.core.domain.TicTacToePlayerBuilder;
26:
27: /**
28: * Implements {@link TicTacToePlayerBuilder}.
29: */
30: final class TicTacToePlayerBuilderImpl implements TicTacToePlayerBuilder {
31:
32: /**
33: * The name of the player.
34: */
35: private Optional<String> name;
36: /**
37: * {@code true} if the player uses crosses, or {@code false} if she uses noughts.
38: */
39: private boolean usingCrosses;
40:
41: /**
42: * Creates an {@link TicTacToePlayerBuilderImpl}.
43: */
44: TicTacToePlayerBuilderImpl() {
45: this.name = Optional.empty();
46: this.usingCrosses = true;
47: }
48:
49: @Override
50: public TicTacToePlayerBuilderImpl changeName(final String newName) {
51: this.name = Optional.of(newName);
52: return this;
53: }
54:
55: @Override
56: public TicTacToePlayerBuilderImpl changeUsingCrosses(final boolean newUsingCrosses) {
57: this.usingCrosses = newUsingCrosses;
58: return this;
59: }
60:
61: @Override
62: public boolean isUsingCrosses() {
63: return this.usingCrosses;
64: }
65:
66: @Override
67: public TicTacToePlayer build() throws GameException {
68: return new TicTacToePlayerImpl(this.name.orElseThrow(), this.usingCrosses);
69: }
70: }