Simplify FoodFactory#generateFood

This commit is contained in:
Kai S. K. Engelbart 2020-07-01 14:29:00 +02:00
parent c7035ff2c5
commit 9131d0e2fd
No known key found for this signature in database
GPG Key ID: 0A48559CA32CB48F
1 changed files with 1 additions and 2 deletions

View File

@ -76,8 +76,7 @@ public class FoodFactory {
* @since Snake 1.0
*/
public Food generateFood() {
int n = new Random().nextInt(Food.values().length + 1);
nextFood = n == Food.values().length ? generateFood() : Food.values()[n];
nextFood = Food.values()[new Random().nextInt(Food.values().length)];
rectangleSize = nextFood.ordinal() + 2;
setTimeToNextFoodMillis();
return nextFood;