How to write a connect4py oop python 27 program with interfa
How to write a connect4.py oop python (2.7) program with interface and instruction below? Please provide runnable python code, thank you so much!
Type of Players Users can choose Player X and Player O to be either human- or computer-controlled. You have to use command line to request for the types of the two players before starting the game (as shown in Figure 3) Please choose the first player Please choose the second player 1.Computer 2. Human Your choice is:1 Player 0 is Computer .Computer 2. Human our choice is:2 Player X is HumanSolution
----------- This is how you implement given diagram in Python OOps --------------------------
class Player:
def __init__(self,playerSymbol):
self.playerSymbol = playerSymbol;
def NextColumn(self, gameBoard):
pass
class Human(Player):
def __init__(self,playerSymbol):
Player.__init__(self,playerSymbol)
def NextColumn(self, gameBoard):
pass
class Computer(Player):
def __init__(self,playerSymbol):
Player.__init__(self,playerSymbol)
def NextColumn(self, gameBoard):
pass
class Connect_Four:
def __init__(self):
self.gameBoard = [[-1]*7]*7
self.player1 = None
self.player2 = None
self.turn = True
def startGame(self):
print(\"Please choose the first Player:\")
print(\"1.Computer\ 2.Human\")
#ch = raw_input(\"Enter a number: \")
ch = int(input(\"Enter a number: \"))
self.player1 = Computer(\'O\') if (int(ch)==1) else Human(\'O\')
print(\"Please choose the Second Player:\")
print(\"1.Computer\ 2.Human\")
ch = int(input(\"Enter a number: \"))
self.player2 = Computer(\'X\') if (int(ch)==1) else Human(\'X\')
while(True):
# your game exit condition
break;
self.printGameBoard()
def printGameBoard(self):
for i in range(0,7):
for j in range(0,7):
print self.gameBoard[i][j],
print(\"\")
if __name__ == \'__main__\':
Connect_Four().startGame()

