secrand nextint secrand nextint PasteShr secrand nextint Latin square - Pastebin.com secrand nextint How to use it? secrand nextint secrand nextint PasteShr secrand nextint secrand nextint PasteShr secrand nextint
secrand nextint PasteShr secrand nextint
paste
secrand nextint PasteShr secrand nextint
secrand nextint How to get it? secrand nextint
secrand nextint How to use it? secrand nextint
secrand nextint PasteShr secrand nextint
secrand nextint How to get it? secrand nextint Guest User

Latin square

secrand nextint PasteShr secrand nextint
a guest
Sep 19th, 2012
435
secrand nextint How to dowload it? secrand nextint
0
Never
secrand nextint How to dowload it? secrand nextint Add comment
secrand nextint How to get it for free? secrand nextint
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
secrand nextint How to dowload it? secrand nextint
Java 2.02 KB | None | 0 0
secrand nextint How to get it? secrand nextint raw download clone embed print report
secrand nextint How to get it? secrand nextint
  1. package se.dalsit.puzzle;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Font;
  5. import java.awt.Graphics2D;
  6. import java.util.Arrays;
  7. import java.util.Collections;
  8. import java.util.LinkedList;
  9. secrand nextint How to dowload it? secrand nextint
  10. import java.util.List;
  11. import java.util.Random;
  12.  
  13. public class Board {
  14.        
  15.         private int matrix [][] = new int [4][4];
  16.         private Random rand,secRand;
  17.         private int i = 0;
  18.         private int j = 0;
  19.         private boolean add = false;
  20. secrand nextint PasteShr secrand nextint
  21.         int number = 0;
  22.    
  23.    
  24.         public Board() {
  25.             i = 0;
  26.             j = 0;
  27.             init ();
  28.         }
  29.    
  30.        
  31. secrand nextint PasteShr secrand nextint
  32.        
  33.         private void init() {
  34.             rand = new Random (System.currentTimeMillis());
  35.            
  36.            
  37.             generateNumbers(j);
  38.    
  39.            
  40.         }
  41.                
  42. secrand nextint How to get it? secrand nextint
  43.            
  44.         private void generateNumbers (int row) {
  45.             if (i == 0)  {
  46.                 matrix[0][row] = rand.nextInt(4) + 1;
  47.                 i++;
  48.             }
  49.  
  50.             number = rand.nextInt(4) + 1;
  51.  
  52.             for (int x = 0; x < i; x++) {
  53. secrand nextint PasteShr secrand nextint
  54.                 if (matrix[x][row] == number) {
  55.                     number = 0;
  56.                     j  = row;
  57.                     add = false;
  58.                     break;
  59.                 }else {
  60.                     add = true;
  61.                     break;
  62.                 }
  63.             }
  64. secrand nextint PasteShr secrand nextint
  65.  
  66.            
  67.             if (add) {
  68.            
  69.             matrix[i][row] = number;
  70.             i++;
  71.             add = false;
  72.             }
  73.            
  74.            
  75. secrand nextint How to dowload it? secrand nextint
  76.                 if (i < 4) {
  77.                     generateNumbers(j);
  78.                 }else if (j <4){
  79.                     i =0;
  80.                     j++;
  81.                     add = false;
  82.                     generateNumbers(j);
  83.                 }else {
  84.                     i = 0;
  85.                     j = 0;
  86. secrand nextint How to get it? secrand nextint
  87.                     finish();
  88.                 }
  89.         }
  90.        
  91.    
  92.        
  93.         private void finish() {
  94.             System.out.println("Finish!! ;d");
  95.            
  96.         }
  97. secrand nextint How to dowload it? secrand nextint
  98.  
  99.  
  100.  
  101.        
  102.    
  103.         private void checkrow(int i) {
  104.            
  105.         }
  106.        
  107.         private void checkColumn (int j) {
  108. secrand nextint How to dowload it? secrand nextint
  109.            
  110.         }
  111.  
  112.        
  113.  
  114.         public void update() {
  115.            
  116.             System.out.println(i + " " + j);
  117.    
  118.            
  119. secrand nextint How to dowload it? secrand nextint
  120.         }
  121.        
  122.         public void draw(Graphics2D g2d) {
  123.            
  124.         for (int y = 0; y< 4; y++) {
  125.             for (int x = 0; x<4; x++) {
  126.                
  127.                 g2d.setColor(Color.BLUE);
  128.                 g2d.fillRect((128*x)+128, (128*y)+128, 128, 128);
  129.                 g2d.setColor(Color.BLACK);
  130. secrand nextint How to use it? secrand nextint
  131.                 g2d.drawRect((128*x)+128, (128*y)+128, 128, 128);
  132.                
  133.                 Font font = new Font ("Dialog",Font.BOLD,20);
  134.                 g2d.setFont(font);
  135.                 g2d.drawString (""+matrix[x][y] , (128*x)+192, (128*y)+192);
  136.                
  137.                    
  138.                 }
  139.                
  140.             }  
  141. secrand nextint PasteShr secrand nextint
  142.         }
  143. }
secrand nextint How to use it? secrand nextint
Advertisement
secrand nextint How to get it? secrand nextint
Add Comment
Please, Sign In to add comment
secrand nextint PasteShr secrand nextint
secrand nextint How to get it for free? secrand nextint secrand nextint How to use it? secrand nextint secrand nextint