тест для Java-кода для цикла с неудачными тестами - PullRequest
0 голосов
/ 30 октября 2018

введите описание изображения здесь / ** Убедитесь, что границы каждой ячейки соответствуют * его соседи. Например, если у клетки нет восточной стены, * тогда у его соседа на востоке не должно быть западной стены. * * В частности: для каждой ячейки в сетке и для каждого направления, * клетка может иметь стену в этом направлении, если * стена находится на краю сетки и должна иметь стену * в этом направлении, если его сосед * в этом направлении имеет соответствующую стену. * * @return Имеют ли ячейки в сетке допустимые значения границ. * / public boolean borderAreValid () { логический результат = true; for (int j = 0; j if (i==0 && !this.cells[j][i].hasWest()) { result = false; } if (j== this.cells.length -1 && this.cells[j][i].hasSouth()) { result = false; } if (i== this.cells.length -1 && this.cells[j][i].hasEast()) { result = false; } } else { Cell northneighbour; Cell southneighbour; Cell eastNeighbour; Cell westNeighbour; northneighbour = this.cells[j-1][i]; southneighbour = this.cells[j+1][i]; eastNeighbour = this.cells[j][i+1]; westNeighbour = this.cells[j][i-1]; if (this.cells[j][i].hasNorth() && !northneighbour.hasSouth() ){ result = false; } if (this.cells[j][i].hasEast() && !northneighbour.hasWest() ){ result = false; } if (this.cells[j][i].hasWest() && !northneighbour.hasEast() ){ result = false; } if (this.cells[j][i].hasSouth() && !northneighbour.hasNorth() ){ result = false; } } } } return result; }

...