Программа запускается, но Painter не рисует?JAVA

Программисты JAVA общаются здесь
Ответить
Anonymous
 Программа запускается, но Painter не рисует?

Сообщение Anonymous »

Я провожу практический урок, где использую вложенный оператор if на сайте code.org, где он хочет, чтобы я закрасил область стены в полосатый цвет по своему выбору. Я правильно написал код, как показано ниже, но по какой-то причине всякий раз, когда я запускаю программу, художник не начинает рисовать. что здесь происходит? я что-то упускаю?
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();
}
}
}

}


Подробнее здесь: https://stackoverflow.com/questions/799 ... wont-paint
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «JAVA»