Reputation: 31
public void runTheHorses()
{
for (int i=0; i < 4; i++) {
if (!gameOver) {
raceDice.rollDice();
if (horses[i].getMovingNumber() < raceDice.getSum()) {
horses[i].updatePosition(raceDice.getDifference());
if (horses[i].getPosition() >= finishLine) {
gameOver=true;
winner=horses[i].getName();
}
}
horses[i].setMovingNumber();
}
}
} // end method
I am making a horse race program. It is just a simple school exercise but when I try to compile it gives me an error message. In the line:
if (horses[i].getMovingNumber**()** < raceDice.getSum()){
Where it is bold, (the brackets after .getMovingNumber), it gives me the " 'void' type not allowed here" error message. I do not know what to do. The original method for getMovingNumber is:
private int movingNumber=4;
public int getMovingNumber()
{
return movingNumber;
}
Upvotes: 0
Views: 826