Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Pictures from the implementation of the program 1. Board - An object representing a tic-tac-toe board a) Attributes gameBoard An array of buttons representing the

Pictures from the implementation of the program

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Carlos Coronel, Steven Morris

14th Edition

978-0357673034

More Books

Students also viewed these Databases questions

Question

7 How should HRM practitioners approach conflict in the workplace?

Answered: 1 week ago