Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help finishing a Floodit game in java listed below in the following paste

ID: 3667542 • Letter: I

Question

I need help finishing a Floodit game in java listed below in the following pastebin files. In specific the flood function inside the Floodfunction class needs to be implemented. The flood() method is for both the player mode and the autoplay mode. The flood function will take one parameter, a color, as an Integer of the color index, ranging from 0 to 5 (representing six colors). The flood function should change the color of the cells in the flood area to the chosen color (the input), and expand the flooded area by including adjacent cells that share the same color. I need the flooded cells to be stored in the member value, floodList, of the FloodFunction class, which by default is a LinkedList. The floodList initially contains the cell at the top-left corner (the seed cell). The following link shows how the game is played out: http://unixpapa.com/floodit/

Constants.java: http://pastebin.com/fSUYbr59

Coord.java: http://pastebin.com/ru7jbgpu

Driver.java: http://pastebin.com/D4mfqpT2

FloodFunction.java: http://pastebin.com/g81WN3pB

GUIFrame.java: http://pastebin.com/4Z2Gtnpv

Explanation / Answer

ANSWER:

Note: User asked only flood() alone.

public void flood(int colorToFlood)

{

          for(Coord coord:floodList)

            {

//check for color of coord

                        if(colorOfCoord(coord)!=colorToFlood)

                                    continue;

//get adjacent cells

                        Coord c1=up(coord);

                        Coord c2=down(coord);

                        Coord c3=left(coord);

                        Coord c4=right(coord);

//check for inbound of adjacent cells & ADD IT TO FLOODLIST

                        if(inbound(c1))

                                    if(!floodList.contains(c1))

                                                floodList.add(c1);

                        if(inbound(c2))

                                    if(!floodList.contains(c2))

                                                floodList.add(c2);

                        if(inbound(c3))

                                    if(!floodList.contains(c3))

                                                floodList.add(c3);

                        if(inbound(c4))

                                    if(!floodList.contains(c4))

                                                floodList.add(c4);                  

            }

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote