import java.awt.Color; import java.util.ArrayList; public class Player { private String name; private boolean robot; private Color color; public Player(){ setName("Player Name"); setRobot(true); setColor(Color.RED); } public Player(String theName){ this(); setName(theName); } public Player(boolean isRobot){ this(); setRobot(isRobot); } public Player(String theName, boolean isRobot){ this(); setName(theName); setRobot(isRobot); } public Player(String theName, Color c){ this(); setName(theName); setColor(c); } /** * @param name the name to set */ public void setName(String name) { this.name = name; } /** * @return the name */ public String getName() { return name; } /** * @param robot define whether the player is a robot or not */ public void setRobot(boolean robot) { this.robot = robot; } /** * @return is the player is a robot or not. */ public boolean isRobot() { return robot; } public int getMove(ArrayList legalMoves){ if (robot){ int choice=randomInt(0,legalMoves.size()); return legalMoves.get(choice); } return -1; } private int randomInt(int min, int max) { return min+(int)((max-min)*Math.random()); } /** * @param color the color to set */ public void setColor(Color color) { this.color = color; } /** * @return the color */ public Color getColor() { return color; } }