Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases New Opportunities For Connected Data

Authors: Ian Robinson, Jim Webber, Emil Eifrem

2nd Edition

1491930896, 978-1491930892

More Books

Students also viewed these Databases questions

Question

explain a strategic approach to reusing waste

Answered: 1 week ago

Question

44. Show that ( ) ( ). Give an interpretation involving subsets.

Answered: 1 week ago

Question

5. If yes, then why?

Answered: 1 week ago

Question

6. How would you design your ideal position?

Answered: 1 week ago