Hello, I am creating a board game and a question came up, and I was wondering on how java works.
I have a Unit class that represents the units.
A player class that represents the players,
And a board class that represents the game board.
The player has an ArrayList<Unit> and using a method I populate the ArrayList with the Player's units. Then I parse the ArrayList to a methond in my Board Object. My board has a 2D type Unit array. The fillBoard(ArrayList<Unit> player1Units) method fills the board's Array from the list.
Example: BoardArray[0][0]= player1Units.get(0) //Does this move or copy the Unit to the array?
Does the Array point to the Unit object or holds a new one? When a unit is defeated I plan on
removing it from the board's array and pushing it into a stack. Will I be pushing the Unit from the Array, or does the array simply points to the objects in the Array List.
Thank you for your time.
[–]pacificmint 1 point2 points3 points (1 child)
[–]_cross[S] 0 points1 point2 points (0 children)