This commit is contained in:
LeterZP
2026-02-13 00:17:04 +03:00
commit da7c6aa397
23 changed files with 760 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
package environment;
import food.*;
import java.util.ArrayList;
public record Environment(ArrayList<Tree> trees,
ArrayList<Plant> plants,
Weather weather,
Ground ground) {
public Environment {
if (ground != Ground.ASPHALT && ground != Ground.SAND) {
if (weather != Weather.WIND) {
int rand = (int) (Math.random() * 8);
for (int i = 0; i < rand; i++) {
trees.add(new Tree());
}
}
if (weather != Weather.SNOW) {
int rand = (int) (Math.random() * 8);
for (int i = 0; i < rand; i++) {
plants.add(new Plant());
}
}
}
}
public Environment() {
this(new ArrayList<>(),
new ArrayList<>(),
Weather.values()[(int) (Math.random() * Weather.values().length)],
Ground.values()[(int) (Math.random() * Ground.values().length)]);
}
}