Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- /**
- * Write a description of class GCNewForest here.
- *
- * @author (your name)
- * @version (a version number or a date)
- */
- public class NewForest
- {
- // instance variables - replace the example below with your own
- private Tree[][] trees;
- private int n;
- /**
- * Constructor for objects of class NewForest
- */
- public NewForest()
- {
- // initialise instance variables
- n = 4;
- // Setting up an array of 4 rows and 4 columns.
- Tree[][] trees = new Tree[4][4];
- // Adding trees into the 2D array.
- for (int i = 0; i < trees.length; i++)
- {
- for (int j = 0; j < trees.length; j++)
- {
- if ((i+j)%2 == 0)
- trees[i][j] = new Ash();
- else
- trees[i][j] = new Beech();
- }
- }
- }
- public Tree getTree(int i, int j)
- {
- if(i < 4 && j < 4)
- {
- Tree trees = Tree[i][j];
- }
- else
- {
- return null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement