'How to use Ascii Code and QList on a Java Chessboard

For my Java chess game, my teacher wants me to use an Ascii Code to give the tiles on the x-axis of the boards letters while the y-axis has numbers (like it is on a real board). I couldn´t find a way to really use Ascii code, so I´m asking if somebody knows how to do that. Furthermore, he wants me to colour the chess tiles black and white like a real chess board too, using a QList, and again, I am completely lost. Below, you can see my class Chessboard where I used an ArrayList to assign letters to the numbers. I´m really struggling with this.

import java.util.*; import java.util.ArrayList;

/**

  • A chessboard consists of 64 tiles, half black and half white, organized in turns. Pieces can move on either colour, but are stationed on certain tiles for the start of the game.
  • @author Alice Auciello
  • @version 2022 */

public class Chessboard extends Game

{

private Piece piece;
protected int startX;
protected int startY;
protected int endX;
protected int endY;
protected String tileCoordinate; 
private int[][] chessboard;
private ArrayList<Piece> pieces;
private ArrayList<Piece> killedPieces;
private boolean tileOccupied;
protected boolean killed;

private Tile[][] boxes;


/**
 * 
 */
public Chessboard()
{
    
    this.setPiece(piece);
    this.setStartX(startX);
    this.setStartY(startY);
    this.setEndX(endX);
    this.setEndY(endY);
    this.tileCoordinate = tileCoordinate;
    this.resetChessboard();   
    new ArrayList<Piece>();
    tileOccupied = false;
    this.chessboard = new int[startX][startY];
    
    this.resetChessboard();
    
            

}

/**
 * The tiles of a chessboard are collected in a two-dimensional Array. The X-axis is ordered in i (numbers from 0-7), the Y-axis in j (letters from A-J). 

 */  
public void resetChessboard() {
// Person muss i und j Werte aussuchen
int[] iNumbers = {0, 1, 2, 3, 4, 5, 6, 7};
int[] jNumbers = {0, 1, 2, 3, 4, 5, 6, 7}; 


    for (int i = 0 ; i <= 7 ; i++){
    for (int j = 0 ; j <= 7 ; j++){
    if (i == 0) {
        System.out.print(jNumbers[j]);
    } else if (j == 0){
        System.out.println(iNumbers[i]);
    } 
    }
    System.out.println();
    }
    
    
    iNumbers1.put(0, "A");
    iNumbers2.put(1, "B");
    iNumbers3.put(2, "C");
    iNumbers4.put(3, "D");
    iNumbers5.put(4, "E");
    iNumbers6.put(5, "F");
    iNumbers7.put(6, "G");
    iNumbers8.put(7, "H");
   
}

    public Tile getBox(int x, int y) {
    if (x < 0 || x > 7 || y < 0 || y > 7) {
        throw new Exception ("Tile out of Chessboard");
    }
    return boxes [x][y];


    
            //white pieces
    boxes[0][0] = new Tile(0, 0, new Rook(true));
    boxes[0][1] = new Tile(0, 1, new Knight(true));
    boxes[0][2] = new Tile(0, 2, new Bishop(true));
    boxes[0][3] = new Tile(0, 3, new King(true));
    boxes[0][4] = new Tile(0, 4, new Queen(true));
    boxes[0][5] = new Tile(0, 5, new Bishop(true));
    boxes[0][6] = new Tile(0, 6, new Knight(true));
    boxes[0][7] = new Tile(0, 7, new Rook(true));
    
    boxes[1][0] = new Tile(1, 0, new Pawn(true));
    boxes[1][1] = new Tile(1, 1, new Pawn(true));
    boxes[1][2] = new Tile(1, 2, new Pawn(true));
    boxes[1][3] = new Tile(1, 2, new Pawn(true));
    boxes[1][4] = new Tile(1, 2, new Pawn(true));
    boxes[1][5] = new Tile(1, 2, new Pawn(true));
    boxes[1][6] = new Tile(1, 2, new Pawn(true));
    boxes[1][7] = new Tile(1, 2, new Pawn(true));
    

    // black pieces
    boxes[7][0] = new Tile(7, 0, new Rook(false));
    boxes[7][1] = new Tile(7, 1, new Knight(false));
    boxes[7][2] = new Tile(7, 2, new Bishop(false));
    boxes[7][3] = new Tile(7, 3, new King(false));
    boxes[7][4] = new Tile(7, 4, new Queen(false));
    boxes[7][5] = new Tile(7, 5, new Bishop(false));
    boxes[7][6] = new Tile(7, 6, new Knight(false));
    boxes[7][7] = new Tile(7, 7, new Rook(false));
    //...
    boxes[6][0] = new Tile(6, 0, new Pawn(false));
    boxes[6][1] = new Tile(6, 1, new Pawn(false));
    boxes[6][2] = new Tile(6, 2, new Pawn(false));
    boxes[6][3] = new Tile(6, 3, new Pawn(false));
    boxes[6][4] = new Tile(6, 4, new Pawn(false));
    boxes[6][5] = new Tile(6, 5, new Pawn(false));
    boxes[6][6] = new Tile(6, 6, new Pawn(false));
    boxes[6][7] = new Tile(6, 7, new Pawn(false));
    
}



public int[][] getChessboard() {

    return chessboard; 
}

public void setChessboard(int[][] board) { this.chessboard = chessboard; }

public void changeXaxis() {
    int min = 0;
    int max = 7;
    
     for (int i = min; i < max; i++) {  
    int tile = (int) i;
    
    
}


} 


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source