-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComputerPlayer.java
More file actions
35 lines (31 loc) · 925 Bytes
/
Copy pathComputerPlayer.java
File metadata and controls
35 lines (31 loc) · 925 Bytes
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
import java.util.Random;
/**
* ComputerPlayer is a concrete class which represents computer as a player
*/
public class ComputerPlayer extends Player {
/**
* Constructor which takes player name and token as input
*
* @param name is the name of player.
* @param token is the token associated with player move.
*/
public ComputerPlayer(String name, Token token) {
super(name, token);
}
/**
*
* @param column is the total number of column in board
*
* @return a random number in the form of String between [ 1 - column ] with a delay of 500 milliseconds
*/
@Override
String getMove(int column) {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
Random random = new Random();
return String.valueOf(random.nextInt(column));
}
}