public void actionPerformed(ActionEvent e){
  setup();
  controller.reset();
  if (computerGoesFirst) {
    controller.playTurn();
  }
  if (computerPlaysSelf) {
    int i=0;
    while (controller.playTurn() == GameController.IN_PROGRESS) {
      if (++i > 100) {
        break;
      }
    }
    int state=controller.getCurrentState();
switch (state) {
case GameController.DRAW:
      applet.output("Game is drawn");
    break;
case GameController.X_WINS:
  applet.output("X Wins!");
break;
case GameController.O_WINS:
applet.output("O Wins!");
break;
}
}
applet.repaint();
}

public void actionPerformed ( ActionEvent e ) { setup ( ) ; controller . reset ( ) ; if ( computerGoesFirst ) { controller . playTurn ( ) ; } if ( computerPlaysSelf ) { int i = 0 ; while ( controller . playTurn ( ) == GameController . IN_PROGRESS ) { if ( ++ i > 100 ) { break ; } } int state = controller . getCurrentState ( ) ; switch ( state ) { case GameController . DRAW : applet . output ( "Game is drawn" ) ; break ; case GameController . X_WINS : applet . output ( "X Wins!" ) ; break ; case GameController . O_WINS : applet . output ( "O Wins!" ) ; break ; } } applet . repaint ( ) ; }
respond to when user pressed on the playbutton .
