Question

Make sure to include: Ship.java, ShipTester.java, Location.java, LocationTester.java, Grid.java, GridTester.java, Player.java, PlayerTester.java, battleship.java. please do every...

Make sure to include:

Ship.java, ShipTester.java, Location.java, LocationTester.java, Grid.java, GridTester.java, Player.java, PlayerTester.java, battleship.java. please do every part, and include java doc and comments

Create a battleship program. Include Javadoc and comments. Grade 12 level coding style using java only. You will need to create a Ship class, Location class, Grid Class, Add a ship to the Grid, Create the Player class, the Battleship class, Add at least one extension. Make sure to include the testers. Starting code/ sample/methods will be given for each class. Thank you.

The first part of writing our Battleship game is to write the Ship.java class. The Ship represents a Ship in the game, or a piece on the board. The Ship has several defining characteristics (think instance variables!) including a position, a length and a direction.

You’ll need a few instance variables

row       - What row location is the ship at?
col       - What column location is the ship at?
length    - How long is this ship?
direction - Is this ship vertical or horizontal?

To keep track of the direction you should use a few constants:

// Direction constants
public static final int UNSET = -1;
public static final int HORIZONTAL = 0;
public static final int VERTICAL = 1;

The Ship class should have one constructor, taking a parameter of the length of the ship.

// Constructor. Create a ship and set the length.
public Ship(int length)

// Has the location been initialized
public boolean isLocationSet()

// Has the direction been initialized
public boolean isDirectionSet()

// Set the location of the ship 
public void setLocation(int row, int col)

// Set the direction of the ship
public void setDirection(int direction)

// Getter for the row value
public int getRow()

// Getter for the column value
public int getCol()

// Getter for the length of the ship
public int getLength()

// Getter for the direction
public int getDirection()

// Helper method to get a string value from the direction
private String directionToString()

// Helper method to get a (row, col) string value from the location
private String locationToString()

// toString value for this Ship
public String toString()

--------------------------------------------------------------------------------------------------------------------------------------------------------

The next class to write is the Location.java file. The Location class stores the information for one grid position.

A location has two defining attributes

1) Is there a ship at this location?

2) What is the status of this location?

The status of this would be whether this position is unguessed, we got a hit, or got a miss.

public static final int UNGUESSED = 0;
public static final int HIT = 1;
public static final int MISSED = 2;

These are the methods you will need to implement for the Location class.

// Location constructor. 
public Location()

// Was this Location a hit?
public boolean checkHit()

// Was this location a miss?
public boolean checkMiss()

// Was this location unguessed?
public boolean isUnguessed()

// Mark this location a hit.
public void markHit()

// Mark this location a miss.
public void markMiss()

// Return whether or not this location has a ship.
public boolean hasShip()

// Set the value of whether this location has a ship.
public void setShip(boolean val)

// Set the status of this Location.
public void setStatus(int status)

// Get the status of this Location.
public int getStatus()

-------------------------------------------------------------------------------------------------------------------------------------------------------

Now that we have written the Ship class and the Location class, the next thing is to write the Grid class. The Grid class represents a Battleship Grid both for the user player and the computer. This will be used both as a grid to track where your ships are, as well as track the guesses that the user or computer has made.

The main state to track in the Grid is a 2-dimensional array of Location objects.

A few important variables you’ll want to have here are

private Location[][] grid;

// Constants for number of rows and columns.
public static final int NUM_ROWS = 10;
public static final int NUM_COLS = 10;

To start off, you should implement the basic functionality to make this Grid class a little easier to use than a simple 2D array. Here are the methods you need to implement.

// Create a new Grid. Initialize each Location in the grid
// to be a new Location object.
public Grid()

// Mark a hit in this location by calling the markHit method
// on the Location object.  
public void markHit(int row, int col)

// Mark a miss on this location.    
public void markMiss(int row, int col)

// Set the status of this location object.
public void setStatus(int row, int col, int status)

// Get the status of this location in the grid  
public int getStatus(int row, int col)

// Return whether or not this Location has already been guessed.
public boolean alreadyGuessed(int row, int col)    

// Set whether or not there is a ship at this location to the val   
public void setShip(int row, int col, boolean val)

// Return whether or not there is a ship here   
public boolean hasShip(int row, int col)


// Get the Location object at this row and column position
public Location get(int row, int col)

// Return the number of rows in the Grid
public int numRows()

// Return the number of columns in the grid
public int numCols()


// Print the Grid status including a header at the top
// that shows the columns 1-10 as well as letters across
// the side for A-J
// If there is no guess print a -
// If it was a miss print a O
// If it was a hit, print an X
// A sample print out would look something like this:
// 
//   1 2 3 4 5 6 7 8 9 10 
// A - - - - - - - - - - 
// B - - - - - - - - - - 
// C - - - O - - - - - - 
// D - O - - - - - - - - 
// E - X - - - - - - - - 
// F - X - - - - - - - - 
// G - X - - - - - - - - 
// H - O - - - - - - - - 
// I - - - - - - - - - - 
// J - - - - - - - - - - 
public void printStatus()

// Print the grid and whether there is a ship at each location.
// If there is no ship, you will print a - and if there is a
// ship you will print a X. You can find out if there was a ship
// by calling the hasShip method.
//
//   1 2 3 4 5 6 7 8 9 10 
// A - - - - - - - - - - 
// B - X - - - - - - - - 
// C - X - - - - - - - - 
// D - - - - - - - - - - 
// E X X X - - - - - - - 
// F - - - - - - - - - - 
// G - - - - - - - - - - 
// H - - - X X X X - X - 
// I - - - - - - - - X - 
// J - - - - - - - - X - 
public void printShips()

----------------------------------------------------------------------------------------------------------------------------------------------------------------

Now we need to extend our Grid class with a new method.

/**
 * This method can be called on your own grid. To add a ship
 * we will go to the ships location and mark a true value
 * in every location that the ship takes up.
 */
public void addShip(Ship s)

This method should go to the Locations in the Grid that the Ship is in and set the boolean value to true to indicate that there is a ship in that location. You have some handy helper methods already to do this!

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Now that we have written Ship, Location, and Grid, now it is time to write the Player class.

Player will handle the logic for our two players, the user player and the computer player.

Each player has a few key characteristics.

They have a list of 5 ships. Each ship is of a set length. You have one ship of length 2, two ships of length 3, one ship of length 4 and one ship of length 5.

Putting these values in an array will be very handy.

// These are the lengths of all of the ships.
private static final int[] SHIP_LENGTHS = {2, 3, 3, 4, 5};

So each Player should have a list of five ships. To store this:

Then each Player also will have 2 Grids. One grid represents that player’s grid, and the other grid represents their opponents grid. On the player’s grid, they will mark the location of their ships, as well as record the guesses of their opponent. On the opponents grid, the player will record their own guesses of where they think the battleships are.

In the constructor you should set up the instance variables.

For testing purposes here you may also want a method like

public void chooseShipLocation(Ship s, int row, int col, int direction)

This will set a ship’s row, column and direction and add it to the current player’s grid. You can use this to hard code in testing placement of battleships.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

In this part we’ll start writing our Battleship class, which hooks all of the parts of our game together.

You’ll want to make two Player objects.

The goal for this part is to create two players, then be able to print out the current board status that they have,
and then make a guess and have it update the underlying data stucture as well as show in the display.

Here you may need to go back and make modifications to your Player class.

We recommend writing a method in the Battleship class called:

askForGuess

Which asks the user player for a valid row and column to guess as a location of the opponents battleship. If there is a ship on the opponents board it should indicate that.

In this part we will finish the Battleship game

Here the key is making the game work really well, testing for robustness so you can’t break the game, and also handling other edge cases.

First, the user should be asked to choose the locations of their battleships at the start.

You should ask for the row, column and direction (horizontal or vertical) in order to place the ships.

Then for the computer player you should automatically generate the locations of the initial ships.

After that you’ll want to alternate with the user making a guess and the computer making a guess. You should continue this until one of the players wins. The winning condition is if you have hit every battleship location.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

This part of the project is for making extensions. There are lots of ways to improve this game. What can you think of? One idea is: can you leave a message if the user has sunk a battle ship? What touches can you add to the game?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please let me know if you have any doubts or you want me to modify the code. And if you find this code useful then don't forget to rate my answer as thumps up. Thank you! :)


import java.io.IOException;
import java.util.Scanner;

public class ShipTester {
    public static void main(String[] args) throws IOException {
        // TODO Auto-generated method stub
        System.out.println("---------------------------------");
        System.out.println("Welcome to Battleship.");
        System.out.println("---------------------------------");
        System.out.println("First you need to choose the location of your ships" + "\n");


        Computer computer = new Computer();
        computer.askForShips();
        Scanner guesses = new Scanner(System.in);
        Player player1 = new Player(guesses, computer.computerGrid);
        player1.askForShips();

        System.out.println("Location of my ships");
        player1.printMyShips();
        System.out.println();

        System.out.println("Enemy has placed ships. " );
        int playerHits = 0;
        int computerHits = 0;
        int totalHits = 17;

        while(true){


            if(totalHits <= playerHits){
                System.out.println("YOU WIN!!");
                break;
            }
            if(computerHits >= totalHits){
                System.out.println("YOU LOSE!!");
                break;
            }


            System.out.println("\n" + "Player Turn to Guess:" + "\n");
            System.out.print("Which row? (1-10) ");
            int shipRow = player1.reader.nextInt()-1;

            System.out.println("Which column? (1-10) ");
            int shipCol = player1.reader.nextInt()-1;

            boolean check = true;
            if(shipRow > 10 || shipCol > 10 || shipRow < 0 || shipCol < 0){
                check = false;
                System.out.println("Invalid Guess. Guess again: ");
            }
            if(check){
                playerHits += computer.recordOpponentGuess(shipRow, shipCol);
                player1.recordMyGuess(shipRow, shipCol);
                player1.printMyGuesses();
                System.out.println("\1"
                        + "1n" + "Computer's turn: ");
                int[] compGuess = computer.getCompGuess();
                computerHits += player1.recordOpponentGuess(compGuess[0], compGuess[1]);
                player1.printOpponentGuesses();

            }

        }

        player1.reader.close();


    }

}
-----------------------------------------------------------------------------------------------
import java.util.Random;

public class Computer {

    private static final int[] SHIP_LENGTHS = {2, 3, 3, 4, 5};
    //private Grid computerGrid;
    public Grid computerGrid;
    private static final int NUM_SHIPS = 5;

    public Computer(){

        computerGrid = new Grid();
    }

    public int recordOpponentGuess(int row, int col) {
        if(computerGrid.hasShip(row, col) == true){
            computerGrid.markHit(row, col);
            return 1;
        }
        else{
            computerGrid.markMiss(row, col);
            return 0;
        }
    }

    public boolean chooseShipLocation(Ship s, int row, int col, int direction){
        s.setLocation(row, col);
        s.setDirection(direction);
        return computerGrid.addShip(s);

    }


    public int[] getCompGuess(){

        int shipRow = 0;
        int shipCol = 0;
        Random random = new Random();

        shipCol = random.nextInt(10);
        shipRow = random.nextInt(10);
        if(computerGrid.alreadyGuessed(shipRow, shipCol)){
            return getCompGuess();
        }
        return new int [] {shipRow, shipCol};

    }

    public void askForShips() {
        int shipRow = 0;
        int shipCol = 0;
        int shipDirection = 0;
        Random random = new Random();

        for (int i = 0; i < NUM_SHIPS; i++) {


            shipRow = random.nextInt(10);
            shipCol = random.nextInt(10);
            shipDirection = random.nextInt(2);
            Ship s = new Ship(SHIP_LENGTHS[i]);
            boolean check = chooseShipLocation(s, shipRow, shipCol, shipDirection);
            if(check == false){
                i--;
            }
        }
    }
}
--------------------------------------------------------------------------------------
public class Grid
{
    private Location[][] grid = new Location[NUM_ROWS][NUM_COLS];;

    // Constants for number of rows and columns.
    public static final int NUM_ROWS = 10;
    public static final int NUM_COLS = 10;


    // Write your Grid class here
    public Grid(){
        for(int row = 0; row < NUM_ROWS; row++){
            for(int col = 0; col < NUM_COLS; col++) {
                grid[row][col] = new Location();
            }
        }


    }

    // Mark a hit in this location by calling the markHit method
// on the Location object.
    public void markHit(int row, int col){
        grid[row][col].markHit();

    }

    // Mark a miss on this location.
    public void markMiss(int row, int col){
        grid[row][col].markMiss();
    }

    // Set the status of this location object.
    public void setStatus(int row, int col, int status){
        grid[row][col].setStatus(status);
    }

    // Get the status of this location in the grid
    public int getStatus(int row, int col){
        return grid[row][col].getStatus();
    }

    // Return whether or not this Location has already been guessed.
    public boolean alreadyGuessed(int row, int col){
        return !grid[row][col].isUnguessed();
    }

    // Set whether or not there is a ship at this location to the val
    public void setShip(int row, int col, boolean val){
        grid[row][col].setShip(val);
    }

    // Return whether or not there is a ship here
    public boolean hasShip(int row, int col){
        return grid[row][col].hasShip();
    }


    // Get the Location object at this row and column position
    public Location get(int row, int col){
        return grid[row][col];
    }

    // Return the number of rows in the Grid
    public int numRows(){
        return NUM_ROWS;
    }

    // Return the number of columns in the grid
    public int numCols(){
        return NUM_COLS;
    }

    //This method can be called on your own grid. To add a ship

    public boolean addShip(Ship s){
        int length = s.getLength();
        if(s.getDirection() == 0){
            if(length + s.getCol() > NUM_COLS){
                return false;
            }
            for(int i = 0; i < s.getLength(); i++){
                if(grid[s.getRow()][s.getCol() + i].hasShip()){
                    return false;
                }
            }
            for(int i = 0; i < s.getLength(); i++){
                grid[s.getRow()][s.getCol() + i].setShip(true);
            }
        }
        else if(s.getDirection() == 1){
            if(length + s.getRow() > NUM_ROWS){
                return false;
            }
            for(int x = 0; x < s.getLength(); x++){
                if(grid[s.getRow() + x][s.getCol()].hasShip()){
                    return false;
                }
            }
            for(int x = 0; x < s.getLength(); x++){
                grid[s.getRow() + x][s.getCol()].setShip(true);
            }
        }
        return true;
    }

    public void printStatus() {
        for (int c = 1; c <= NUM_COLS; c++) {
            if (c == NUM_COLS) {
                System.out.print(c);
            }
            else if(c == 1){
                System.out.print(" " + c + " ");
            }
            else{
                System.out.print(c + " ");
            }

        }
        System.out.print("\n");

        for (int i = 0; i < grid.length; i++) {
            int t = ('A' + i);
            char cur = (char) t;
            System.out.print(cur + " ");
            for (int j = 0; j < grid[0].length; j++) {
                if (grid[i][j].checkHit()) {
                    System.out.print("X ");
                } else if (grid[i][j].checkMiss()) {
                    System.out.print("O ");
                } else {
                    System.out.print("- ");
                }
            }
            System.out.print("\n");
        }
    }

    public void printShips(){
        for (int c = 1; c <= NUM_COLS; c++) {
            if (c == NUM_COLS) {
                System.out.print(c);
            }
            else if(c == 1){
                System.out.print(" " + c + " ");
            }
            else {
                System.out.print(c + " ");
            }
        }

        System.out.print("\n");

        for (int i = 0; i < grid.length; i++) {
            int t = ('A' + i);
            char cur = (char) t;
            System.out.print(cur + " ");
            for (int j = 0; j < grid[0].length; j++) {
                if (grid[i][j].hasShip()) {
                    System.out.print("X ");
                } else {
                    System.out.print("- ");
                }
            }
            System.out.print("\n");
        }
    }
}
-----------------------------------------------------------------------------------------
public class Location
{
    public static final int UNGUESSED = 0;
    public static final int HIT = 1;
    public static final int MISSED = 2;
    private boolean ship;
    private int shipStat;

    //Implement the Location class here
    // Location constructor.
    public Location(){
        this.ship = false;
        this.shipStat = UNGUESSED;

    }

    // Was this Location a hit?
    public boolean checkHit(){
        if(shipStat == HIT){
            return true;
        }

        return false;
    }

    // Was this location a miss?
    public boolean checkMiss(){
        if(shipStat == MISSED){
            return true;
        }

        return false;
    }

    // Was this location unguessed?
    public boolean isUnguessed(){
        if(shipStat == UNGUESSED){
            return true;
        }

        return false;

    }

    // Mark this location a hit.
    public void markHit(){
        shipStat = HIT;
    }

    // Mark this location a miss.
    public void markMiss(){
        shipStat = MISSED;
    }

    // Return whether or not this location has a ship.
    public boolean hasShip(){
        return ship;
    }

    // Set the value of whether this location has a ship.
    public void setShip(boolean val){
        ship = val;

    }

    // Set the status of this Location.
    public void setStatus(int status){
        shipStat = status;
    }

    // Get the status of this Location.
    public int getStatus(){
        return shipStat;

    }
}
-------------------------------------------------------------------------------------
import java.util.Scanner;

public class Player
{
    private static final int[] SHIP_LENGTHS = {2, 3, 3, 4, 5};
    private Grid playerGrid;
    private Grid opponentGrid;
    private static final int NUM_SHIPS = 5;
    public Scanner reader;

    public Player(Scanner x, Grid compGrid){

        reader = x;
        playerGrid = new Grid();
        opponentGrid = compGrid;
    }

    public void printMyShips() {

        playerGrid.printShips();
    }

    public void printOpponentGuesses() {
        playerGrid.printStatus();

    }

    public void printMyGuesses() {
        opponentGrid.printStatus();
    }

    public int recordOpponentGuess(int row, int col) {
        if(playerGrid.hasShip(row, col) == true){
            playerGrid.markHit(row, col);
            return 1;
        }
        else{
            playerGrid.markMiss(row, col);
            return 0;
        }
    }

    public int recordMyGuess(int row, int col){
        if(opponentGrid.hasShip(row, col) == true){
            opponentGrid.markHit(row, col);
            return 1;
        }
        else{
            opponentGrid.markMiss(row, col);
            return 0;
        }
    }

    public boolean chooseShipLocation(Ship s, int row, int col, int direction){
        s.setLocation(row, col);
        s.setDirection(direction);
        return playerGrid.addShip(s);

    }

    public void askForShips() {
        int shipRow = 0;
        int shipCol = 0;
        int shipDirection = 0;

        for (int i = 0; i < NUM_SHIPS; i++) {

            System.out.println("Your current grid of ships.");
            printMyShips();
            System.out.println();

            System.out.println("Now you need to place a ship of length " + Player.SHIP_LENGTHS[i] + ".");
            System.out.print("Which row? (1-10) ");
            shipRow = reader.nextInt()-1;
            System.out.println("Which column? (1-10) ");
            shipCol = reader.nextInt()-1;
            System.out.println("Which direction? (0 aka horizontal or 1 aka verticle) ");
            shipDirection = reader.nextInt();
            Ship s = new Ship(SHIP_LENGTHS[i]);
            boolean check = chooseShipLocation(s, shipRow, shipCol, shipDirection);
            if(check == false){
                System.out.println("Invalid location. Pick new location: ");
                i--;
            }


        }

    }
}
----------------------------------------------------------------------------------------------
public class Ship
{
    public static final int UNSET = -1;
    public static final int HORIZONTAL = 0;
    public static final int VERTICAL = 1;
    int row;
    int col;
    int length;
    int direction;

    // Constructor. Create a ship and set the length.
    public Ship(int length){
        this.length = length;
        this.row = UNSET;
        this.col = UNSET;
        this.direction = UNSET;

    }

    // Has the location been initialized
    public boolean isLocationSet(){
        if(row != UNSET && col != UNSET){
            return true;
        }
        else{
            return false;
        }
    }

    // Has the direction been initialized
    public boolean isDirectionSet(){
        if(direction != UNSET){
            return true;
        }
        else{
            return false;
        }
    }

    // Set the location of the ship
    public void setLocation(int row, int col){
        this.row = row;
        this.col = col;
    }

    // Set the direction of the ship
    public void setDirection(int direction){
        this.direction = direction;
    }

    // Getter for the row value
    public int getRow(){
        return row;
    }

    // Getter for the column value
    public int getCol(){
        return col;
    }

    // Getter for the length of the ship
    public int getLength(){
        return length;
    }

    // Getter for the direction
    public int getDirection(){
        return direction;
    }

    // Helper method to get a string value from the direction
    private String directionToString(){
        String theDirect = "";
        if(direction == HORIZONTAL){
            theDirect = "horizontal";
        }
        else if(direction == VERTICAL){
            theDirect = "vertical";
        }
        else if(direction == UNSET){
            theDirect = "unset direction";
        }
        return theDirect;

    }

    // Helper method to get a (row, col) string value from the location
    private String locationToString(){
        String theLocat = "(" + Integer.toString(row) + ", " + Integer.toString(col) + ")";
        if(isLocationSet() == false){
            theLocat = "(unset location)";
        }
        return theLocat;
    }

    // toString value for this Ship
    public String toString(){
        return directionToString() + " ship of length " + Integer.toString(length) + " at " + locationToString();
    }

}


圃Ship [~Ndeaprojects/Shipl-,../src/Shipiava [Ship] Ship src Ship Main /Library/Java/JavaVirtualMachines/jdk-9.8.4.jdk/Content

Add a comment
Know the answer?
Add Answer to:
Make sure to include: Ship.java, ShipTester.java, Location.java, LocationTester.java, Grid.java, GridTester.java, Player.java, PlayerTester.java, battleship.java. please do every...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Programming Language : JAVA Write a class named Ship. Its purpose is to model a ship...

    Programming Language : JAVA Write a class named Ship. Its purpose is to model a ship in the BattleShip game and its placement on the Battleship board. Ships exist on a 10 x 10 battleship board with ten rows labeled A through J and columns labeled 1 through 9 and the final column labeled 0 to indicate the tenth column. We will refer to the Ship placed on the board at the origin which the pair (r,c) where in the...

  • Assignment - Battleship In 1967, Hasbro toys introduced a childrens game named “Battleship”. In the next...

    Assignment - Battleship In 1967, Hasbro toys introduced a childrens game named “Battleship”. In the next two assignments you will be creating a one-player version of the game. The game is extremely simple. Each player arranges a fleet of ships in a grid. The grid is hidden from the opponent. Here is an ASCII representation of a 10x10 grid. The ‘X’s represent ships, the ‘~’s represent empty water. There are three ships in the picture: A vertical ship with a...

  • C#: Implement a multiplayer Battleship game with AI The rules are the same as before. The...

    C#: Implement a multiplayer Battleship game with AI The rules are the same as before. The game is played on an NxN grid. Each player will place a specified collection of ships: The ships will vary in length (size) from 2 to 5; There can be any number or any size ship. There may be no ships of a particular size; EXCEPT the battleship – which there will always be 1 and only 1. Player order will be random but...

  • I need help finishing my C++ coding assignment! My teacher has provided a template but I...

    I need help finishing my C++ coding assignment! My teacher has provided a template but I need help finishing it! Details are provided below and instructions are provided in the //YOU: comments of the template... My teacher has assigned a game that is similar to battleship but it is single player with an optional multiplayer AI... In the single player game you place down a destroyer, sub, battleship, and aircraft carrier onto the grid.... Then you attack the ships you...

  • For your Project, you will develop a simple battleship game. Battleship is a guessing game for...

    For your Project, you will develop a simple battleship game. Battleship is a guessing game for two players. It is played on four grids. Two grids (one for each player) are used to mark each players' fleets of ships (including battleships). The locations of the fleet (these first two grids) are concealed from the other player so that they do not know the locations of the opponent’s ships. Players alternate turns by ‘firing torpedoes’ at the other player's ships. The...

  • C++ Trek Wars Project: 100% code coverage unit testing is required for this project. once a ship has reached 0 health it...

    C++ Trek Wars Project: 100% code coverage unit testing is required for this project. once a ship has reached 0 health it is considered blown up -throw an exception if the move method is called on it. -repair ships cannot repair ships at 0 health There will be no chaotic corvette ships Trek Wars Purpose: classes, inheritance, class diagrams, virtual, testing Description Universal Merriment Development (UMD) is creating an online space battle game called (Trek Wars) You are tasked with...

  • JAVA Only Help on the sections that say Student provide code. The student Provide code has...

    JAVA Only Help on the sections that say Student provide code. The student Provide code has comments that i put to state what i need help with. import java.util.Scanner; public class TicTacToe {     private final int BOARDSIZE = 3; // size of the board     private enum Status { WIN, DRAW, CONTINUE }; // game states     private char[][] board; // board representation     private boolean firstPlayer; // whether it's player 1's move     private boolean gameOver; // whether...

  • This is my code for my game called Reversi, I need to you to make the...

    This is my code for my game called Reversi, I need to you to make the Tester program that will run and complete the game. Below is my code, please add comments and Javadoc. Thank you. public class Cell { // Displays 'B' for the black disk player. public static final char BLACK = 'B'; // Displays 'W' for the white disk player. public static final char WHITE = 'W'; // Displays '*' for the possible moves available. public static...

  • i need this in C# please can any one help me out and write the full...

    i need this in C# please can any one help me out and write the full code start from using system till end i am confused and C# is getting me hard.I saw codes from old posts in Chegg but i need the ful complete code please thanks. Module 4 Programming Assignment – OO Design and implementation (50 points) Our Battleship game needs to store a set of ships. Create a new class called Ships. Ships should have the following...

  • Looking at this method, it returns true if a given location contains a real ship that...

    Looking at this method, it returns true if a given location contains a real ship that is still afloat. It says "real" ship because the 'emptySea' class extends Ship class with an inherited length of one, saving the need for null checks as empty locations now contain a non-null value meaning it does not contain a ship. 'isOccupied' will return true if that location contains a ship. The 'ships' array is used to determine which ship is in that location....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT