Skip to content

style: linting of FloodFill #4361

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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