HW09: Color Fill due Mon 27 Mar 10:00

This assignment requires the use of 2-dimensional arrays and gi...
...tunity to create code in accordance with a pre-defined structure.

The Program

In this assignment you will create a class called MyCanvas that will perform a “fill” operation on an ASCII canvas. The canvas will be represented as a two-dimensional array of chars and will be defined in a text file that contains on the first line the number of rows and number of columns in the canvas (separated by a space). The remainder of the file has characters filling the number of rows and columns specified.

Here is an example input file:

10 10
1 1      1
1   1 1 11
1  1 1  11
111    1 1
1  1 1   1
11111 1111
1    1   1
1111  11 1

Your program will implement a color filling algorithm that given a starting position and a drawing color (i.e., a character) will fill in any open space with the specified drawing color. Of course to know what we mean by “open space” we have to name a border color. So, if we view `1' as our border color and we wanted to fill in the space at the top of the canvas we would use the following commands:

   MyCanvas canvas= new MyCanvas();

   canvas.load("image1.txt"); // loads image from file into canvas
   canvas.setBorder('1');     // specifies that 1 is the border character
   canvas.fill('*',0,0);      // starting at position (0,0) fill area with *'s
   canvas.show();             // display the canvas

When the canvas is displayed we would expect to see this:

1  1*1***1
11111 1111
1    1   1
1111  11 1

Notice that the color fills up, down, right, and left, but not diagonally.


NOTE: Use the original Driver.java provided in the original lab day assignment to demonstrate your program.

The assignment will be graded according to the following criteria:

Correctness 16 pts
Documentation 2 pts
Conventions 2 pts
Version Control 2 pts
Total 22 pts

Your program should be completely working and should follow all of the programming conventions named in class and explained in http://josephus.hsutx.edu/classes/all/javaconventions/ (including the use of comments that conform to the JavaDoc guidelines).

The instructor will grade your work based on what you have pushed to the hosted homework repository you have shared. For all assignments the program is due before the beginning of class on the due date. Repositories that show a commit time after that time will be graded as late.