This commit is contained in:
Ninja-Jambon 2024-02-20 20:19:03 +01:00
parent 56e0195600
commit 4f59633394
4 changed files with 74 additions and 0 deletions

44
Universe.java Normal file
View file

@ -0,0 +1,44 @@
// Antoine CRETUAL, Lukian LEIZOUR, 14/02/2024
public class Universe {
// Atributes
private int[][] grid;
private int length, height;
// Constructors
public Universe(int length, int height) {
this.grid = new int[height][length];
this.height = height;
this.length = length;
int i, j;
for (i = 1; i < this.height - 1; i++) {
for (j = 1; j < this.length - 1; j++) {
grid[i][j] = 0;
}
}
for (i = 0; i < this.height; i++) {
grid[i][0] = -1;
grid[i][length - 1] = -1;
}
for (j = 0; j < this.length; j++) {
grid[0][j] = -1;
grid[height - 1][j] = -1;
}
}
// Methods
public void print() {
int i, j;
for (i = 0; i < this.height; i++) {
for (j = 0; j < this.length; j++) {
System.out.printf("%3d", this.grid[i][j]);
}
System.out.print("\n");
}
}
}