-
Notifications
You must be signed in to change notification settings - Fork 0
/
Player.java
76 lines (67 loc) · 1.96 KB
/
Player.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import java.util.Scanner;
/**
* This class represents a Player of the reversi game.
*
* @author Aaron Martinez <[email protected]>
* @author Matt Butcher <[email protected]>
*
*/
public abstract class Player {
protected int score; //The total number of game pieces on the board
protected char myPiece; //An X or O depending on the player
protected char opponentsPiece; //The opposite of myPiece
/**
* The purpose of this method is to be overridden by each type
* of player in a different manner.
* @return String
* This string contains the indices of the move
* that the player wishes to do.
*/
public abstract String move();
/**
* Sets the instance variable myPiece to the value passed in as the
* parameter.
* @param piece
* Either an O or X depending on the player using the method.
*/
public void setMyPiece(char piece) {
myPiece = piece;
opponentsPiece = ' ';
if(myPiece == 'X')
opponentsPiece = 'O';
else
opponentsPiece = 'X';
}
/**
* Returns the instance variable myPiece of the player using the method.
* @return myPiece
* An instance variable that is either a O or X.
*/
public char getMyPiece() {
return myPiece;
}
/**
* Returns the instance variable opponentsPiece of the player using the method.
* @return opponentsPiece
* An instance variable that is either a O or X.
*/
public char getOpponentsPiece() {
return opponentsPiece;
}
/**
* Retrieves the value of the instance variable score.
* @return score
* The number of a player's game pieces on the board.
*/
public int getScore() {
return score;
}
/**
* Sets the value of the instance variable score.
* @param score
* The number of a player's game pieces on the board.
*/
public void setScore(int score) {
this.score = score;
}
}