Skip to content

Package: SspSayStoneStrategy

SspSayStoneStrategy

nameinstructionbranchcomplexitylinemethod
SspSayStoneStrategy(SspMoveFactory)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
computeNextMove(int, SspPlayer, SspState)
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: 0 C: 12
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
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%
toString()
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%

Coverage

1: /*
2: * Copyright © 2021-2023 Fachhochschule für die Wirtschaft (FHDW) Hannover
3: *
4: * This file is part of ipspiel23-Ssp.
5: *
6: * Ipspiel23-Ssp is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
7: * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
8: * version.
9: *
10: * Ipspiel23-Ssp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
11: * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12: *
13: * You should have received a copy of the GNU General Public License along with ipspiel23-Ssp. If not, see
14: * <http://www.gnu.org/licenses/>.
15: */
16: package de.fhdw.gaming.ipspiel23.ssp.strategy;
17:
18: import de.fhdw.gaming.ipspiel23.ssp.domain.SspPlayer;
19: import de.fhdw.gaming.ipspiel23.ssp.domain.SspState;
20: import de.fhdw.gaming.ipspiel23.ssp.domain.SspStrategy;
21: import de.fhdw.gaming.ipspiel23.ssp.moves.SspMove;
22: import de.fhdw.gaming.ipspiel23.ssp.moves.factory.SspMoveFactory;
23:
24: import java.util.Optional;
25:
26: /**
27: * Implements {@link SspStrategy} by always saying "stone".
28: */
29: public final class SspSayStoneStrategy implements SspStrategy {
30:
31: /**
32: * The factory for creating SSP moves.
33: */
34: private final SspMoveFactory moveFactory;
35:
36: /**
37: * Creates an {@link SspSayStoneStrategy}.
38: *
39: * @param moveFactory The factory for creating SSP moves.
40: */
41: SspSayStoneStrategy(final SspMoveFactory moveFactory) {
42: this.moveFactory = moveFactory;
43: }
44:
45: @Override
46: public Optional<SspMove> computeNextMove(final int gameId, final SspPlayer player, final SspState state) {
47: return Optional.of(this.moveFactory.createStoneMove());
48: }
49:
50: @Override
51: public String toString() {
52: return SspSayStoneStrategy.class.getSimpleName();
53: }
54:
55: @Override
56: public boolean equals(final Object obj) {
57:• return obj != null && this.toString().equals(obj.toString());
58: }
59:
60: @Override
61: public int hashCode() {
62:
63: return super.hashCode() * this.toString().hashCode();
64: }
65: }