fb818d7ab8
git-subtree-dir: Programming/ProgLab3 git-subtree-mainline:329aa90447git-subtree-split:da7c6aa397
34 lines
1.0 KiB
Java
34 lines
1.0 KiB
Java
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)]);
|
|
}
|
|
}
|