SORRY FOR THE WALL OF TEXT, but i have no idea how ask in a shorter way.
Hi,
i'm pretty new to Java and want to program the game Battleships object orientated. At first for the Terminal, but i want to keep it in a way to be able to add a GUI (JavaFX) later to it.
Now i run in a general planning issue with my functions. How much should they do and should they call each other or should a controller handle it.
Here is an example for the game battleships.
I have a class Ship, a class Tile (which is one tile of the grid) and a Controller.
If a tile gets shoot, should:
- should i write custom functions that make sure, everything is handled the right way themselves?
- or the game controller handle everything with getter and setter methods ( and pretty much ignore relationships in the class diagram)
for example:
a tile gets shoot at and these things need to be done:
- Check if a
shipis on thetile - if there is no
shipon thetilejust change the status toMISSED-> DONE, leave the function - if there is a
shipon thetile, change the status toHIT - then check if the
shipwas hit on all its parts and should sink now. - If it should sink, change status of
shiptoSUNK
Again should a GameController handle all these steps or should a method in Tile maybe even the method from 1. call a method in Shipto check if it should sink, than sink it and than set itself to SUNK?
oh, i hope people can understand what i mean.
Ill write an example to make my question clear, just need some time.