Program runs, but Painter won't Paint?

1 week ago 11
ARTICLE AD BOX

I'm doing a practice lesson where I'm using Nested if statement on code.org where it wants me to paint the area in the wall a striped color of my choice. I got the code right, as seen below, but for some reason whenever I run the program, it's not making the painter paint. what's going on here? am I missing anything?

import org.code.neighborhood.*; /* * A Painter that paints rows in The Neighborhood */ public class RowPainter extends Painter { /* * Sets the x and y values to the starting x and y location, * direction to the specified starting direction, and paint * to the specified starting paint amount */ public RowPainter(int x, int y, String direction, int paint) { super(x, y, direction, paint); } /* * Turns the RowPainter object to the right */ public void turnRight() { turnLeft(); turnLeft(); turnLeft(); } /* * Moves the RowPainter object forward in the direction it is facing if it can move */ public void moveIfCanMove() { if (canMove()) { move(); } } /* * Paints a row in The Neighborhood with firstColor * then moves to the next row with secondColor */ public void paintArea(String firstColor, String secondColor) { while (canMove()) { paintEast(firstColor); paintWest(secondColor); moveIfCanMove(); if (!canMove()) { paintEast(firstColor); paintWest(secondColor); moveToNextRow(); } } } public void paintEast(String color) { if ((getY() == 3%4) && (isFacingEast())){ paint(color); } } public void paintWest(String color) { if ((getY() == 12%4) && (isFacingEast())){ if (hasPaint()){ paint(color); } } } public void moveToNextRow() { if (canMove("south")) { if (facingEast()) { turnRight(); moveIfCanMove(); turnRight(); } else { turnLeft(); moveIfCanMove(); turnLeft(); } } } }

Coder101's user avatar

3

Read Entire Article