Answered step by step
Verified Expert Solution
Question
1 Approved Answer
SOLVE IN JAVA. EXTRA HELPFUL CODE: LEAFPILE.JAVA: public class LeafPile { public static void main(String[] args) { Ground map[][] = new Ground[7][11]; generateRandomGround(map); printMap(map); System.out.println(largestLeafPile(map));
SOLVE IN JAVA.
EXTRA HELPFUL CODE:
LEAFPILE.JAVA:
public class LeafPile {
public static void main(String[] args) {
Ground map[][] = new Ground[7][11];
generateRandomGround(map);
printMap(map);
System.out.println(largestLeafPile(map));
}
/**********Student code here***************************/
private static int largestLeafPile(Ground map[][]) {
}
/***************End Student Code************************/
private static void printMap(Ground map[][]) {
for (int r = 0; r
for (int c = 0; c
System.out.print(map[r][c]);
if (c
System.out.print(' ');
}
}
System.out.println();
}
}
private static void generateRandomGround(Ground map[][]) {
double randGround;
double randMax = 100;
double percentGrass = .70;
for (int r = 0; r
for (int c = 0; c Map 1 Output 4 Map 2 Output 6 Map 3
randGround = (Math.random() * randMax) + 1;
map[r][c] = randGround
}
}
}
}
GROUND.JAVA:
public enum Ground {
GRASS('-'), LEAF('~');
private char symbol;
private Ground(char value) {
symbol = value;
}
public String toString() {
return "" + symbol;
}
}
POSITION.JAVA:
public class Position {
public final int row;
public final int column;
public Position(int row, int column) {
this.row = row;
this.column = column;
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started