I'm creating a ticket reservation system in Java, I want to use a Two-dimensional String array for managing the seats. I have enums that hold the plane model and the amount of seats available so the array pulls the rows and columns from there. I just want to see efficient my code is and how can I improve it.
public String[][] createSeatArray() {
String[] alphabet = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r"
,"s","t","u","v","w","x","y","z","aa","bb","cc","dd","ee","ff","gg","hh","ii","jj","kk","ll","mm","nn","oo","pp"};
String[][] seatArray = new String[this.getNumOfRows()][this.getNumOfColumns()];
int alphabetPos = 0;
for(int i = 0; i < this.getNumOfRows(); i++) {
for (int j = 1; j <= this.getNumOfColumns(); j++){
String columnToString = String.valueOf(j);
seatArray[i][j-1] = alphabet[alphabetPos] + columnToString;
if (this.getNumOfColumns() == 4) {
if (j == 2) {
System.out.print(seatArray[i][j-1] + " ");
} else {
System.out.print(seatArray[i][j-1] + " ");
}
} else {
if (j == 3) {
System.out.print(seatArray[i][j-1] + " ");
} else {
System.out.print(seatArray[i][j-1] + " ");
}
}
}
System.out.println("\n");
alphabetPos++;
}
return seatArray;
}
Thank you for any feedback! also keep in mind that if the indentation is off it may be due to bringing it over to stack overflow, on intellij it's perfect.