Print generation header formatted correctly

This commit is contained in:
Stefan Waldmann
2022-01-17 19:08:19 +01:00
parent 8df8eb6165
commit 064907c83e

View File

@@ -134,7 +134,7 @@ public class Life {
}
private void printGeneration() {
System.out.println("GENERATION: " + generation + " POPULATION: " + population);
printGenerationHeader();
for (int y = 0; y < matrix.length; y++) {
for (int x = 0; x < matrix[y].length; x++) {
System.out.print(matrix[y][x] == 1 ? "*" : " ");
@@ -143,6 +143,11 @@ public class Life {
}
}
private void printGenerationHeader() {
String invalidText = invalid ? "INVALID!" : "";
System.out.printf("GENERATION: %-13d POPULATION: %d %s\n", generation, population, invalidText);
}
/**
* Main method that starts the program.
*