Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n = 4;
- trees = new Tree[n][n];
- int treeCount = 0;
- Random rand = new Random();
- int randomNumTrees = rand.nextInt(n*n/2)+n*n/2;
- while(treeCount <= randomNumTrees){
- int i = rand.nextInt(n);
- int j = rand.nextInt(n);
- if(trees[i][j] == null){
- if(rand.nextInt(2) == 0){
- trees[i][j] = new Ash();
- }
- else{
- trees[i][j] = new Beech();
- }
- treeCount++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement