Created
June 11, 2023 18:32
-
-
Save odds-get-evened/5aabcca73ee48c9f0b7d868669739d24 to your computer and use it in GitHub Desktop.
Grid Window (Main)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.mintaka5; | |
import org.mintaka5.ui.GridWindow; | |
import java.util.Random; | |
public class Main { | |
public static void main(String[] args) { | |
int[][] randGrid = randomGrid(25, 25); | |
printGrid(randGrid); | |
GridWindow gWin = new GridWindow(randGrid, new int[]{10, 10}); | |
// new TestingGraphics(); | |
} | |
private static void printGrid(int[][] randGrid) { | |
for(int[] row : randGrid) { | |
for(int cell : row) { | |
System.out.print(cell); | |
} | |
System.out.println(); | |
} | |
} | |
private static int[][] randomGrid(int rowSize, int colSize) { | |
int[] vals = {0, 1}; | |
int[][] arr = new int[rowSize][colSize]; | |
for(int i=0; i<rowSize; i++) { | |
for(int j=0; j<colSize; j++) { | |
int r = new Random().nextInt(vals.length); | |
arr[i][j] = vals[r]; | |
} | |
} | |
return arr; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment