From 89c4a92d72fdd2c0e12e537079023f7acd6e05a6 Mon Sep 17 00:00:00 2001 From: Paulina Nowak Date: Sun, 20 Dec 2020 02:13:38 +0100 Subject: [PATCH] oeo --- main.py | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/main.py b/main.py index 4f1d2ac..c312c81 100644 --- a/main.py +++ b/main.py @@ -6,14 +6,33 @@ | | """ -def print_board(state): - board = ""+ state[0] +"|"+ state[1] +"|"+ state[2] +" \n-|-|-\n"+ state[3] +"|"+ state[4] +"|"+ state[5] +"\n-|-|-\n"+ state[6] +"|"+ state[7] +"|"+ state[8] +"\n" - print(board) +class TicTacToe: + def __init__(self): + self.state = list(" "*9) -state = list(" "*9) -print_board(state) + def print(self): + board = ""+ self.state[0] +"|"+self.state[1] +"|"+self.state[2] +" \n-|-|-\n"+self.state[3] +"|"+self.state[4] +"|"+self.state[5] +"\n-|-|-\n"+self.state[6] +"|"+self.state[7] +"|"+self.state[8] +"\n" -state[0] = "X" -print_board(state) \ No newline at end of file + print(board) + + def make_move(self, token, field): + if self.state[field] == " ": + self.state[field] = token + else: + print("This field's taken.") + + +game = TicTacToe() +game.print() + +game.make_move("X", 0) +game.print() + +# make_move(state, "X", 0) +# print_board(state) +# make_move(state, "O", 3) +# print_board(state) +# make_move(state, "X", 0) +# print_board(state) \ No newline at end of file