Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Help me developing this code in C++ You're implementing a server for your own Sea Battle game. In this game, each player has a rectangular
Help me developing this code in C++
You're implementing a server for your own Sea Battle game. In this game, each player has a rectangular grid with several ships on it. Each ship can be placed either horizontally or vertically. A ship can't intersect with any other ship, but it can touch them. Given the first player's game grid populated with several ships and several shots made by the second player, implement a function that goes through the shots one by one and returns the effect of each: If a shot didn't hit a ship, the result is "Missed"; If a shot hit a cell that has already been attacked, the result is "Already attacked"; If a shot hit ship x and it's not the last remaining cell of this ship, the result is "Attacked ship " If a shot hit ship x and it is the last cell of this ship, the result is "Ship sunk" Example For grid = [[".", "1", "2", "2", "-"], ["", "1", "3"], ["4", "4", "5", "5", "5"]] and shots [[0, 0], [0, 1], [0, 2], [1, 1], [0, 1], [1, 4], [2, 2], [2, 4], [0, 3], [1, 3], [1, 4]]
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