I'm building a version of battleships, two arrays are created, x and y, when added to the array list Ships. When i run the program i get the same variables appearing in each instance of the array. Any ideas?
posted 4 years ago
The member x of each instance of Ship refers to same array instance created in init(). It's the same for y. You need to create a new ones.