Question: Writing player and method programming in detail, each according to its type, for example class, method h, or others Possible Object Design 1. Board -

Writing player and method programming in detail, each according to its type, for example class, method h, or others

Possible Object Design

1. Board - An object representing a tic-tac-toe board a) Attributes

gameBoard An array of buttons representing the board

b) Methods

i. Constructors

a. Board() - Initializes the board to an empty board

b. Board(JButton [] inBoard) - Initializes the board to inBoard

ii. Accessors

a. boolean submitMove(String move, char player) - adds the move to the board, and returns true if the space specified in the move is not taken. If the space is taken, do not add the move and return false.

b. boolean isWinner(char player) - Returns true if the player whose marker is passed as a parameter has won the game, false otherwise.

c. boolean isCat() - Returns true if there is a CAT(tie), false otherwise

. d. boolean isMoveValid(String move) - Returns true if the parameter is a move on the board, otherwise it returns false

2. Player An object representing a player of the tic-tac-toe game

a) Attributes

char marker - Character representing whether this player is using X or O as her marker

boolean isHuman - Boolean indicating if the player is a human player or a computer playe

b) Methods

i. Constructors

a. Player() - Initializes the marker to X and isHuman to true

b. Player(boolean inIsHuman) - Initializes isHuman to inIsHuman and if inIsHuman is true, marker to X, otherwise marker to O

c. Player(boolean inIsHuman, char inMarker) - Initializes isHuman to inIsHuman and marker to X if inMarker is X or x, otherwise marker to O

ii. Accessors

a. char getMarker() - Returns the players marker

b. boolean getIsHuman() - Returns whether the player is human or not

c. String getPlayerMove() - Returns the move from the player (either from human or computer).

d. StringgetHumanMove() - Prompts the user for a move, retreieves input from the keyboard, and returns it.

e. String generateComputerMove() - Returns a move randomly generated.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!