You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
947 B
41 lines
947 B
import java.util.Collection;
|
|
import java.util.Iterator;
|
|
|
|
public class Player {
|
|
|
|
String name;
|
|
Figure[] figures;
|
|
int startHome;
|
|
int endHome;
|
|
|
|
public Player (String name, int startHome, int endHome) {
|
|
this.name = name;
|
|
this.startHome = startHome;
|
|
this.endHome = endHome;
|
|
figures = new Figure[4];
|
|
for(int i = 0; i < 4; i++) {
|
|
this.figures[i] = new Figure();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return name;
|
|
}
|
|
|
|
public int rollDice() {
|
|
return (int) (Math.random() * 6 + 1);
|
|
}
|
|
|
|
public boolean checkGameWin(Collection<Figure> figures) {
|
|
Iterator<Figure> it = figures.iterator();
|
|
Figure f;
|
|
for(;it.hasNext();) {
|
|
f = it.next();
|
|
if(!(f.getPosition() >= startHome && f.getPosition() <= endHome)) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
}
|