Advertisement
Guest User

Untitled

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