Question: 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
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
