Skip to content

Package: OthelloPlayerBuilderImpl

OthelloPlayerBuilderImpl

nameinstructionbranchcomplexitylinemethod
OthelloPlayerBuilderImpl()
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%
changeUsingBlackTokens(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%
isUsingBlackTokens()
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 © 2020 Fachhochschule für die Wirtschaft (FHDW) Hannover
3: *
4: * This file is part of othello-core.
5: *
6: * Othello-core is free software: you can redistribute it and/or modify
7: * it under the terms of the GNU General Public License as published by
8: * the Free Software Foundation, either version 3 of the License, or
9: * (at your option) any later version.
10: *
11: * Othello-core is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: * GNU General Public License for more details.
15: *
16: * You should have received a copy of the GNU General Public License
17: * along with othello-core. If not, see <http://www.gnu.org/licenses/>.
18: */
19: package de.fhdw.gaming.othello.core.domain.impl;
20:
21: import java.util.Optional;
22:
23: import de.fhdw.gaming.core.domain.GameException;
24: import de.fhdw.gaming.othello.core.domain.OthelloPlayer;
25: import de.fhdw.gaming.othello.core.domain.OthelloPlayerBuilder;
26:
27: /**
28: * Implements {@link OthelloPlayerBuilder}.
29: */
30: final class OthelloPlayerBuilderImpl implements OthelloPlayerBuilder {
31:
32: /**
33: * The name of the player.
34: */
35: private Optional<String> name;
36: /**
37: * If {@code true}, the player will be using black tokens, else she will be using white tokens.
38: */
39: private boolean usingBlackTokens;
40:
41: /**
42: * Creates an {@link OthelloPlayerBuilderImpl}.
43: */
44: OthelloPlayerBuilderImpl() {
45: this.name = Optional.empty();
46: this.usingBlackTokens = true;
47: }
48:
49: @Override
50: public OthelloPlayerBuilderImpl changeName(final String newName) {
51: this.name = Optional.of(newName);
52: return this;
53: }
54:
55: @Override
56: public OthelloPlayerBuilderImpl changeUsingBlackTokens(final boolean newUsingBlackTokens) {
57: this.usingBlackTokens = newUsingBlackTokens;
58: return this;
59: }
60:
61: @Override
62: public boolean isUsingBlackTokens() {
63: return this.usingBlackTokens;
64: }
65:
66: @Override
67: public OthelloPlayer build() throws GameException {
68: return new OthelloPlayerImpl(this.name.orElseThrow(), this.usingBlackTokens);
69: }
70: }