| Summary: | It is found that there was no coordinate for user's reference, so that they have to count to get the coordinate. | ||
|---|---|---|---|
| Product: | CS3343 2020 Group 9_Chinese Chess | Reporter: | DUAN Longteng <longtduan2-c> |
| Component: | ChessGame | Assignee: | DUAN Longteng <longtduan2-c> |
| Status: | RESOLVED FIXED | ||
| Severity: | major | CC: | longtduan2-c |
| Priority: | --- | ||
| Version: | V2.0 | ||
| Hardware: | PC | ||
| OS: | Windows | ||
|
Description
DUAN Longteng
2020-11-14 00:11:20 HKT
The problem is solved and the new code is:
public void printChessBoard() {
int maxChessNameLenwithSpace = 15;
for(int i=9;i>=0;i--) {
System.out.print(i);
for(int j=0;j<9;j++) {
int fill;
if(this.chessBoardDetails[j][i] != null)
fill = maxChessNameLenwithSpace - this.chessBoardDetails[j][i].length();
else
fill = 14;
int leftfill = fill/2;
int rightfill = fill - leftfill;
for(int k=0;k<leftfill;k++)
System.out.print('-');
if (this.chessBoardDetails[j][i] != null)
System.out.print(this.chessBoardDetails[j][i]);
else
System.out.print('+');
for(int k=0;k<rightfill;k++)
System.out.print('-');
}
if(i == 0) {
System.out.println();
System.out.println(" 0 1 2 3 4 5 6 7 8 ");
return;
}
else if (i == 5) {
System.out.println();
System.out.println(" | | | | | | | | | | |");
System.out.println(" | | | | | | | | | | |");
System.out.println(" | | | | | | | | | | |");
}
else {
System.out.println();
System.out.println(" | | | | | | | | | | |");
System.out.println(" | | | | | | | | | | |");
}
}
}
Add: Steps to produce this bug: Typing "new game", A initial game board appears, The chessboard has no coordinate. Engineer to solve this bug: DUAN Longteng |