Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This method returns the coordinates in a game of Battleship. Why is the array declared with two integers instead of one? It would be very
This method returns the coordinates in a game of Battleship. Why is the array declared with two integers instead of one? It would be very helpful if someone could comment each line of code so I can get a better understanding of what is going on. Thanks. public int[] getCoordinates(String input) { int[] coordinates = new int[2]; String[] strList = input.split(" "); int row = strList[0].charAt(0) - 'a'; int col = Integer.parseInt(strList[1]); coordinates[0] = row; coordinates[1] = col; return coordinates; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started