Професионална програма
Loading...
+ Нов въпрос
MartinBG avatar MartinBG 3751 Точки
Best Answer

Не спазвае тази част от условието:

If he tries to move outside of the field, he is punished - he loses the last letter in the string, if there are any, and the player’s position is not changed.

Например:

    private static void up(char[][] matrix) {
        if (wormRow == 0){
            if (matrix[matrix.length - 1][wormCol] == '-'){
                if (worm.length() > 0){
                    worm = worm.substring(0, worm.length() - 1);
                }
            } else {
                matrix[matrix.length - 1][wormCol] = '-';
            }
        } else {
           // ...
        }
    }

// трябва да стане:

    private static void up(char[][] matrix) {
        if (wormRow == 0){
            if (!worm.isEmpty()) {
                worm = worm.substring(0, worm.length() - 1);
            }
        } else {
           // ...
        }
    }

Аналогично и за останалите 3 метода за движение.

0
25/06/2020 16:09:51
desiska avatar desiska 5 Точки

Благодаря ви за бързия отговор!

1
riyasarkar avatar riyasarkar 0 Точки

I have customized an app named gbwhatsapp in which I saw some error but now successfully fixed.

0
Netflix avatar Netflix 1 Точки

Above are the best award winning free online tests for Advance Java Exam Preparation. Our Patented Exam Preparation Algorithm made us bag this award. watch more Latest Hourly Updated NfCookies.com 

 

0