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-2023 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.othello.core.domain.OthelloPlayer;
24: import de.fhdw.gaming.othello.core.domain.OthelloPlayerBuilder;
25:
26: /**
27: * Implements {@link OthelloPlayerBuilder}.
28: */
29: final class OthelloPlayerBuilderImpl implements OthelloPlayerBuilder {
30:
31: /**
32: * The name of the player.
33: */
34: private Optional<String> name;
35: /**
36: * If {@code true}, the player will be using black tokens, else she will be using white tokens.
37: */
38: private boolean usingBlackTokens;
39:
40: /**
41: * Creates an {@link OthelloPlayerBuilderImpl}.
42: */
43: OthelloPlayerBuilderImpl() {
44: this.name = Optional.empty();
45: this.usingBlackTokens = true;
46: }
47:
48: @Override
49: public OthelloPlayerBuilderImpl changeName(final String newName) {
50: this.name = Optional.of(newName);
51: return this;
52: }
53:
54: @Override
55: public OthelloPlayerBuilderImpl changeUsingBlackTokens(final boolean newUsingBlackTokens) {
56: this.usingBlackTokens = newUsingBlackTokens;
57: return this;
58: }
59:
60: @Override
61: public boolean isUsingBlackTokens() {
62: return this.usingBlackTokens;
63: }
64:
65: @Override
66: public OthelloPlayer build() {
67: return new OthelloPlayerImpl(this.name.orElseThrow(), this.usingBlackTokens);
68: }
69: }