Java classes and the 'new' word
If you have a multidimensional array in a class and some methods. A state class.
And other classes that built on that:
State: including your array
And you had a method (say move(int) - this is a game) in state accessible from PlayerTypeA/B. I assume you need State game =new State(); in both player classes and Play. The problem is the array in each class seems unique.
How would I stop the deep copy effect from other classes. I need to affect the one in state using the methods in state. I dont know how to make my self clear. I am stuck on a uni assignment and cannot post code. It is the last bit and too late to ask for help. My methods in state cannot read the changes by my player classes, even though they can use the classes and print them. See my other post. Please help.
the player class initializes state game
but move seems to add the changes to a new array unique to that player class
Re: Java classes and the 'new' word
You dont need to do that in the classes constructors ;). Create the state object before you create instances of those classes and pass it along into their constructors.