Skip to content

Package: VGPlayerImpl

VGPlayerImpl

nameinstructionbranchcomplexitylinemethod
VGPlayerImpl(String, boolean)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
VGPlayerImpl(VGPlayer)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
deepCopy()
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: 2 C: 19
90%
M: 2 C: 4
67%
M: 2 C: 2
50%
M: 1 C: 3
75%
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%
isUsingRedChips()
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%
toString()
M: 0 C: 31
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%

Coverage

1: package de.fhdw.gaming.ipspiel22.vierGewinnt.domain.impl;
2:
3: import de.fhdw.gaming.core.domain.AbstractPlayer;
4: import de.fhdw.gaming.ipspiel22.vierGewinnt.domain.VGFieldState;
5: import de.fhdw.gaming.ipspiel22.vierGewinnt.domain.VGPlayer;
6:
7: /**
8: * Implements {@link VGPlayer}.
9: */
10: public class VGPlayerImpl extends AbstractPlayer<VGPlayer> implements VGPlayer {
11:
12: /**
13: * {@code true} if this player uses the red tokens, or {@code false} if she uses the yellow tokens.
14: */
15: private final boolean usingRedChips;
16:
17: /**
18: * Creates a Vier gewinnt player.
19: *
20: * @param name The name of the player.
21: * @param usingRedChips The possible outcomes of this player. The key for the first-level map is the answer of
22: * the first player, the key for the second-level map is the answer of the second player.
23: */
24: VGPlayerImpl(final String name, final boolean usingRedChips) {
25: super(name);
26: this.usingRedChips = usingRedChips;
27: }
28:
29: /**
30: * Creates a Vier gewinnt player.
31: *
32: * @param source The {@link VGPlayer} to copy.
33: */
34: VGPlayerImpl(final VGPlayer source) {
35: super(source);
36: this.usingRedChips = source.isUsingRedChips();
37: }
38:
39: @Override
40: public String toString() {
41: return String
42: .format("GDPlayer[name=%s, chips=%s, state=%s, outcome=%s]",
43: this.getName(),
44:• this.usingRedChips ? VGFieldState.RED.toString() : VGFieldState.YELLOW.toString(),
45: this.getState(), this.getOutcome());
46: }
47:
48: @Override
49: public boolean equals(final Object obj) {
50:• if (obj instanceof VGPlayerImpl) {
51: final VGPlayerImpl other = (VGPlayerImpl) obj;
52:• return super.equals(obj) && this.usingRedChips == other.usingRedChips;
53: }
54: return false;
55: }
56:
57: @Override
58: public int hashCode() {
59: return super.hashCode() ^ Boolean.hashCode(this.usingRedChips);
60: }
61:
62: @Override
63: public boolean isUsingRedChips() {
64: return this.usingRedChips;
65: }
66:
67: @Override
68: public VGPlayer deepCopy() {
69: return new VGPlayerImpl(this);
70: }
71: }