Answered step by step
Verified Expert Solution
Link Copied!

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. image text in transcribed
image text in transcribed
image text in transcribed
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
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;
}
}
Map 1 Output 4 Map 2 Output 6 Map 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management Systems Designing And Building Business Applications

Authors: Gerald V. Post

1st Edition

0072898933, 978-0072898934

More Books

Students also viewed these Databases questions

Question

73 Adult learning processes.

Answered: 1 week ago

Question

What is the difference between Needs and GAP Analyses?

Answered: 1 week ago

Question

What are ERP suites? Are HCMSs part of ERPs?

Answered: 1 week ago