是偶数:
如果被even
除的值2
没有余数,则返回true;否则,返回假。
可以移动:
如果当前街道 ( this.getStreet()
) 是偶数,则使用当前大道 ( this.getAvenue()
);否则,使用 4 - 当前大道。其结果存储在avenues
.
如果当前街道乘以 5++ avenues
a roll 值小于 25,则返回 true;否则返回假;
重写,这可能是:
private boolean canMove(int roll) {
// create the avenues variable and initialize it with a value
int avenues = 0;
// if this.getStreet() is even, then avenues = this.getAvenue()
if (isEven(this.getStreet()) {
avenues = this.getAvenue();
// otherwise, avenues = 4 - this.getAvenue()
} else {
avenues = 4 - this.getAvenue();
}
// if this.getStreet() * 5 + avenues + roll is less than 25, then return true
if (this.getStreet() * 5 + avenues + roll < 25) {
return true;
}
// otherwise, return false
return false;
}