subject

Write a class named tictactoe that has two private data members: the board, which will be a list of lists that represent a 3x3 board, and the current state. it should have a get method named get_current_state. the class should have an init method that initializes the board to a list of three lists that each contain three empty strings (where each represents an empty square), and initializes the current_state to "unfinished". it should have a method named make_move that takes three parameters, a row and a column (in that order) where each is an integer in the range 0-2, and either 'x' or 'o' to indicate the player who is making the move. if the row or column are out of bounds, or if that square is already occupied, or if the game has already been won or drawn, make_move should return false. otherwise, it should record the move, update current_state to the appropriate value, and return true. the possible values of current_state are: "x_won", "o_won", "draw", or "unfinished". it's possible for multiple moves to be made in a row for the same player. a game is drawn when all of the squares are filled, but neither player has won. it's not required, but you'll probably find it useful for testing and debugging to have a method that prints out the board. whether you think of the array indices as being [row][column] or [column][row] doesn't matter as long as you're consistent. code must be in python, not c++ or java.

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 23:10, Tatertotzzzz
Write a method that accepts a string object as an argument and returns the number of words it contains. for instance, if the argument is "four score and seven years ago", the method should return the number 6. demonstrate the method in a program that asks the user to input a string and then passes that string into the method, printing out whatever the method returns.
Answers: 3
image
Computers and Technology, 23.06.2019 21:00, shyshy1791
Which set of steps will organize the data to only show foods with more than 100 calories and rank their sugar content from greatest to least?
Answers: 1
image
Computers and Technology, 24.06.2019 04:30, andrespacheco5888
Which of the following terms refers to a collection of different types of software that share the goal of infiltrating a computer and making it do something? a- malware b- virus c- spyware d- trojan horse
Answers: 2
image
Computers and Technology, 24.06.2019 14:30, ari313
Two students are discussing the flow of electricity. student a says that voltage is a measure of the amount of electron flow in a circuit. student b says that power is the product of voltage and current. which of the following statements is correct? a. only student a is correct b. only student b is correct c. both of the two students are correct d. neither of the two students is correct
Answers: 1
You know the right answer?
Write a class named tictactoe that has two private data members: the board, which will be a list of...

Questions in other subjects:

Konu
Mathematics, 13.06.2020 01:57