Advertisement
Guest User

Untitled

a guest
Nov 15th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.15 KB | None | 0 0
  1. import java.util.Random;
  2. import Prog1Tools.IOTools;
  3.  
  4. public class BinaryMap {
  5.  
  6.     public static void main(String[] args) {
  7.         boolean[][] array = generateRandomArray();
  8.  
  9.         //  for (int i = 0; i < array.length; i++) {
  10.         //     printArray(array[i]);
  11.         // }
  12.     }
  13.  
  14.     private static void printArray(boolean[] booleans) {
  15.     }
  16.  
  17.     /**
  18.      * Ändert einen Wert im gegebenen daten-Array;
  19.      * aus wahr wird falsch und aus falsch wird wahr
  20.      *
  21.      * @param daten - Array welches verändert werden soll
  22.      * @param x     - x-Koordinate des Wertes
  23.      * @param y     - y-Koordinate des Wertes
  24.      */
  25.     static void updateArray(boolean[][] daten, int x, int y) {
  26.     }
  27.  
  28.     private static boolean[][] generateRandomArrayFix() {
  29.  
  30.         // Random rand = new Random();
  31.         /*
  32.          * 10 random aus 100
  33.          */
  34.  
  35.         boolean[][] randomArray;
  36.  
  37.         int x = 10, y = 10;
  38.         randomArray = new boolean[x][y];
  39.         for (x = 0; x < randomArray.length; x++) {
  40.             for (y = 0; y < randomArray.length; y++) {
  41.                 randomArray[x][y] = false;
  42.  
  43.             }
  44.  
  45.         }
  46.         return randomArray;
  47.     }
  48.  
  49.     private static boolean[][] generateRandomArray() {
  50.  
  51.  
  52.         Random rand = new Random();
  53.         int rowWidth = IOTools.readInt("Enter Grid Width: ");
  54.         int colHeight = IOTools.readInt("Enter Grid Height: ");
  55.  
  56.  
  57.         boolean[][] board = new boolean[rowWidth][colHeight];
  58.  
  59.         for (int idx = 1; idx <= 10; ++idx) {
  60.             //fill the grid
  61.             for (int row = 0; row < board.length; row++) {
  62.  
  63.                 for (int col = 0; col < board[row].length; col++) {
  64.  
  65.                     board[col][row] = rand.nextBoolean();
  66.                 }
  67.             }
  68.  
  69.             //display output
  70.             for (int i = 0; i < board.length; i++) {
  71.  
  72.                 for (int j = 0; j < board[i].length; j++) {
  73.  
  74.                     System.out.print(board[i][j] + " ");
  75.                     //System.out.println();
  76.                 }
  77.                 System.out.println();
  78.             }
  79.             return board;
  80.         }
  81.         return board;
  82.     }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement