Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. n = 4;
  2. trees = new Tree[n][n];
  3. int treeCount = 0;
  4. Random rand = new Random();
  5.  
  6. while(treeCount <= rand.nextInt(n*n/2)+n*n/2){
  7. int i = rand.nextInt(n);
  8. int j = rand.nextInt(n);
  9. if(trees[i][j] == null){
  10. if(rand.nextInt(2) == 0){
  11. trees[i][j] = new Ash();
  12. }
  13. else{
  14. trees[i][j] = new Beech();
  15. }
  16. treeCount++;
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement