Skip to content

Commit

Permalink
Fix formatting of FloodFill (TheAlgorithms#4361)
Browse files Browse the repository at this point in the history
  • Loading branch information
vil02 authored Sep 9, 2023
1 parent a88abb7 commit c54b8cd
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/main/java/com/thealgorithms/backtracking/FloodFill.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
* Java program for Flood fill algorithm.
* @author Akshay Dubey (<a href="https://github.com/itsAkshayDubey">Git-Akshay Dubey</a>)
*/
public class FloodFill {
public final class FloodFill {
private FloodFill() {
}

/**
* Get the color at the given coordinates of a 2D image
Expand All @@ -14,7 +16,7 @@ public class FloodFill {
* @param y The y co-ordinate of which color is to be obtained
*/

public static int getPixel(int[][] image, int x, int y) {
public static int getPixel(final int[][] image, final int x, final int y) {
return image[x][y];
}

Expand All @@ -25,7 +27,7 @@ public static int getPixel(int[][] image, int x, int y) {
* @param x The x co-ordinate at which color is to be filled
* @param y The y co-ordinate at which color is to be filled
*/
public static void putPixel(int[][] image, int x, int y, int newColor) {
public static void putPixel(final int[][] image, final int x, final int y, final int newColor) {
image[x][y] = newColor;
}

Expand All @@ -38,11 +40,10 @@ public static void putPixel(int[][] image, int x, int y, int newColor) {
* @param newColor The new color which to be filled in the image
* @param oldColor The old color which is to be replaced in the image
*/
public static void floodFill(int[][] image, int x, int y, int newColor, int oldColor) {
if (newColor == oldColor) return;
if (x < 0 || x >= image.length) return;
if (y < 0 || y >= image[x].length) return;
if (getPixel(image, x, y) != oldColor) return;
public static void floodFill(final int[][] image, final int x, final int y, final int newColor, final int oldColor) {
if (newColor == oldColor || x < 0 || x >= image.length || y < 0 || y >= image[x].length || getPixel(image, x, y) != oldColor) {
return;
}

putPixel(image, x, y, newColor);

Expand Down

0 comments on commit c54b8cd

Please sign in to comment.