Programming Assignment 8 (optional)

Due May 5, before midnight

Program Description

In this assignment you must implement a recursive method to simulate a grassfire. A two-dimensional array is used to represent areas of dry grass (yellow) and wet grass (green). For a given starting point, your algorithm will determine what grass, if any, burns (turning any burnt grass black). An example is shown below:




Example input image
Grassfire starting point shown in red
Resulting burnt area after simulation

The fire can only burn yellow grass. Once yellow grass burns, it's color is set to black. Note also that the fire cannot burn any green grass.
Fire can only spread to any of the 8 neighboring locations in the 2D grass array: above, below, to the left, and to the right (as shown in white below), as well as adjacent diagonals (as shown below in black).

        

What You Do

It is assumed that you are using NetBeans to develop your code for this assignment.  Create a new NetBeans project that is a "General" "Java Application". Name your NetBeans project program8.

Download the source for the Main.java,
Grass.java, and Burn.java classes, and store these in the program8/src/program8 directory.  Also download the test files: test0.png, test1.png, test2.png, test3.png, test4.png, and store these in your directory program8.

Using NetBeans,
you are to implement a recursive static method for the class Burn:
  1. public static void fire(int[][] lawn, int x, int y)
This recursive method simulates a grass fire over the lawn 2D array, given a fire starting point x,y.

Programming Style

You are expected to follow the CS111 / CS112 Java Coding Standard.  You will be graded on programming style. Each student must schedule two meetings with course staff to review a submitted program's style.   Two lab times will be set aside for this (refer to course schedule).  You can also arrange to have tutors review your program style during scheduled tutoring hours.   This is meant to allow students to get guidance and feedback on style, and the grading of style is separate from the grading of Program Assignment 7.

Testing

You are responsible for testing your method.  To help you in testing, a few example tests are provided in the file Main.java.  Other tests will be conducted in grading -- so test your methods carefully before submitting your code.
Here are the test cases provided, and the correct solutions:

test cases 

What You Submit

Submit your  file called Burn.java in a directory named 08 via gsubmit .

Under no circumstances will late assignments be accepted.

Grading Criteria



20% Submitted code compiles without errors
40% fire
produces the correct results for the cases given in Main.java
40% fire produces the correct values for the cases given at testing time