I am having an issue with a program i am creating as part of an on-line Java course.
I have to create a game of battleships where the computer generates positions for a fleet of ships and the player shoots them down as fast as possible.
It also needs to have save/load functionality. This is where I have encountered a problem.
I have managed to read the positions etc for the fleet of ships that has to be loaded in. I have also managed to read in the shots that the user has fired. But i can not get these shots to show on screen like they do when i click on a button to shoot in this grid position.
Here is the code for shooting a ship (via pressing on its grid square (it works))
Here is the setGuiSquare method:
And here is the code that does work, but does not change the button like it does when you click on a button:
Note that the correct variables seem to be being passed into the method. The bnum (number of button in the array) seems to be correct and the correct char seems to also be being returned into the method (it is infact detecting if a ship has been hit)
has anyone got any idea why the buttons are not being changed?
I dont know if this is at all needed. But here is the whole class i have used for the GUI/game controll. I realise the code is messy.
Thank you for any help in advance!