May someone please do this assignment?

1 answer below »
May someone please do this assignment?
Answered Same DayDec 06, 2021

Answer To: May someone please do this assignment?

Arun Shankar answered on Dec 09 2021
159 Votes
import java.util.Random;
import java.util.Scanner;
public class Driver
{
    static char[][] grid
= new char[5][5];
    static char[][] player = new char[5][5];
    static Scanner scan = new Scanner(System.in);
    
    public static boolean checkvicinity(int row, int col)
    {
        for (int i=row-1;i<=row+1;i++)
            for(int j= col-1;j<=col+1;j++)
            {
                if((i>=0) && (i<5) && (j>0) && (j<5))
                    if(grid[i][j]=='X')    // There's a ship in the vicinity of (row,col)
                        return true;
            }
        return false;    //There's no ship in the vicinity
    }
    
    public static void initialize_player()
    {
        for(int i=0;i<5;i++)
            for(int j=0;j<5;j++)
                player[i][j] = ' ';
    }
    
    public static void show_player_grid()
    {
        for(int...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here