Question: JAVA So, I got so far code. Array of sea is the array where are storing also all deployed ships of game, shipSize is user

JAVA

So, I got so far code. Array of sea is the array where are storing also all deployed ships of game, shipSize is user provided size of deployable ship. All is great and ok with other my not added there code, but i am confused how to add within this part or maybe as other function(method) of checking does on sea already has ship (marked as X) - then it is not possible to start row positioning and after by columns. If There is no X - then we can deploy ship. And other problem there is, that neccessary to implement moment, that also next to position cannot be used for ship deployment. For example, if ship stays on [10][1] (one unit ship), then next ship CANNOT be deployed also on [10][2], [9][1] (something like perimeter). Oh, and yes, sea size is 10x10 by array if it makes sence for this moment.

public void Deployment(char [][] sea, int shipSize) { Scanner scanner = new Scanner(System.in); System.out.print("Enter row where to start (1-10): "); int row = Integer.parseInt(scanner.nextLine()); System.out.print("Start position your ship (on columns 1-10): "); for(int i=1; i<=shipSize; i++){ int column = Integer.parseInt(scanner.nextLine()); sea[row][column] = 'X'; } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!