mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-23 07:29:02 -08:00
Print generation header formatted correctly
This commit is contained in:
@@ -134,7 +134,7 @@ public class Life {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void printGeneration() {
|
private void printGeneration() {
|
||||||
System.out.println("GENERATION: " + generation + " POPULATION: " + population);
|
printGenerationHeader();
|
||||||
for (int y = 0; y < matrix.length; y++) {
|
for (int y = 0; y < matrix.length; y++) {
|
||||||
for (int x = 0; x < matrix[y].length; x++) {
|
for (int x = 0; x < matrix[y].length; x++) {
|
||||||
System.out.print(matrix[y][x] == 1 ? "*" : " ");
|
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.
|
* Main method that starts the program.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user