Skip to content

Method: toString()

1: /*
2: * Copyright © 2021-2023 Fachhochschule für die Wirtschaft (FHDW) Hannover
3: *
4: * This file is part of ipspiel23-demo.
5: *
6: * Ipspiel23-demo 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-demo 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-demo. If not, see
14: * <http://www.gnu.org/licenses/>.
15: */
16: package de.fhdw.gaming.ipspiel23.demo.strategy;
17:
18: import java.util.Optional;
19:
20: import de.fhdw.gaming.ipspiel23.demo.domain.DemoPlayer;
21: import de.fhdw.gaming.ipspiel23.demo.domain.DemoState;
22: import de.fhdw.gaming.ipspiel23.demo.domain.DemoStrategy;
23: import de.fhdw.gaming.ipspiel23.demo.moves.DemoMove;
24: import de.fhdw.gaming.ipspiel23.demo.moves.factory.DemoMoveFactory;
25:
26: /**
27: * Implements {@link DemoStrategy} by always saying "no".
28: */
29: public final class DemoSayNoStrategy implements DemoStrategy {
30:
31: /**
32: * The factory for creating Demo moves.
33: */
34: private final DemoMoveFactory moveFactory;
35:
36: /**
37: * Creates an {@link DemoSayNoStrategy}.
38: *
39: * @param moveFactory The factory for creating Demo moves.
40: */
41: DemoSayNoStrategy(final DemoMoveFactory moveFactory) {
42: this.moveFactory = moveFactory;
43: }
44:
45: @Override
46: public Optional<DemoMove> computeNextMove(final int gameId, final DemoPlayer player, final DemoState state) {
47: return Optional.of(this.moveFactory.createNoMove());
48: }
49:
50: @Override
51: public String toString() {
52: return DemoSayNoStrategy.class.getSimpleName();
53: }
54: }