JAVA编写的问题,现在一个class的开始部分,我不知道怎么开始写

来源:百度知道 编辑:UC知道 时间:2024/07/03 01:04:16
/**
* Game class. Represents one game of battleships. Each Game has
* two Players. The Game keeps track of whose turn it is, and is
* responsible for determining which Player has won.
*/
public class Game {
public static final int GRID_SIZE = 10; // The height and width of the grid - DO NOT CHANGE

/**
* Game Constructor. Creates this game's players from the specified names.
* Also initialises the game so that player 1 starts first.
* @param player1Name The name of player 1.
* @param player2Name The name of player 2.
*/
public Game(String player1Name, String player2Name) { }

/** @return Returns player 1. */
public Player getPlayer1() { }

/** @return Returns player 2. */
public Player getPlayer2() { }

/**
* Advances the game to the next turn - that is, makes it the next player's turn.
* This method will never be called if the G

首先,你要定义两个player对象,在Game类里头。
nextTurn() {}这个里头,按你自己的需求写。。
/**
* Game class. Represents one game of battleships. Each Game has
* two Players. The Game keeps track of whose turn it is, and is
* responsible for determining which Player has won.
*/
public class Game {
public static final int GRID_SIZE = 10; // The height and width of the grid - DO NOT CHANGE

private Player player1;
private Player player2;
/**
* Game Constructor. Creates this game's players from the specified names.
* Also initialises the game so that player 1 starts first.
* @param player1Name The name of player 1.
* @param player2Name The name of player 2.
*/
public Game(String player1Name, String player2Name) {
player1.name = player1Name;
player2.name = player2Name;
}

/** @return Returns player 1. */
public Player getPlayer1() {
return player1;
}

/**