|
@ -678,6 +678,64 @@ public class TikTakToeGame extends JFrame{ |
|
|
}//end else |
|
|
}//end else |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
btnNewButton8.addActionListener(new ActionListener() { |
|
|
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
|
if(spielerIstDran == 1) { |
|
|
|
|
|
btnNewButton8.setForeground(new Color(255, 0, 0)); |
|
|
|
|
|
btnNewButton8.setBackground(new Color(255, 0, 0)); |
|
|
|
|
|
btn8 = "red"; |
|
|
|
|
|
|
|
|
|
|
|
btnNewButton8.setEnabled(false); |
|
|
|
|
|
if(btn8.equals("red") && btn7.equals("red") && btn9.equals("red") || |
|
|
|
|
|
btn8.equals("red") && btn5.equals("red") && btn2.equals("red")) { |
|
|
|
|
|
TextFieldAusgabe1.setText("Spieler 1 Hat gewonnen."); |
|
|
|
|
|
punkte1 +=1; |
|
|
|
|
|
|
|
|
|
|
|
btnNewButton1.setEnabled(false); |
|
|
|
|
|
btnNewButton2.setEnabled(false); |
|
|
|
|
|
btnNewButton3.setEnabled(false); |
|
|
|
|
|
btnNewButton4.setEnabled(false); |
|
|
|
|
|
btnNewButton5.setEnabled(false); |
|
|
|
|
|
btnNewButton6.setEnabled(false); |
|
|
|
|
|
btnNewButton7.setEnabled(false); |
|
|
|
|
|
btnNewButton9.setEnabled(false); |
|
|
|
|
|
}//end if |
|
|
|
|
|
else { |
|
|
|
|
|
TextFieldAusgabe1.setText("Der Spieler 2 ist dran."); |
|
|
|
|
|
spielerIstDran = 2; |
|
|
|
|
|
}//end else |
|
|
|
|
|
}//end if |
|
|
|
|
|
else if(spielerIstDran == 2){ |
|
|
|
|
|
btnNewButton8.setForeground(new Color(0, 0, 255)); |
|
|
|
|
|
btnNewButton8.setBackground(new Color(0, 0, 255)); |
|
|
|
|
|
btn8 = "blue"; |
|
|
|
|
|
|
|
|
|
|
|
btnNewButton8.setEnabled(false); |
|
|
|
|
|
if(btn8.equals("blue") && btn7.equals("blue") && btn9.equals("blue") || |
|
|
|
|
|
btn8.equals("blue") && btn5.equals("blue") && btn2.equals("blue")) { |
|
|
|
|
|
TextFieldAusgabe1.setText("Spieler 2 Hat gewonnen."); |
|
|
|
|
|
punkte2 +=1; |
|
|
|
|
|
|
|
|
|
|
|
btnNewButton1.setEnabled(false); |
|
|
|
|
|
btnNewButton2.setEnabled(false); |
|
|
|
|
|
btnNewButton3.setEnabled(false); |
|
|
|
|
|
btnNewButton4.setEnabled(false); |
|
|
|
|
|
btnNewButton5.setEnabled(false); |
|
|
|
|
|
btnNewButton6.setEnabled(false); |
|
|
|
|
|
btnNewButton7.setEnabled(false); |
|
|
|
|
|
btnNewButton9.setEnabled(false); |
|
|
|
|
|
}//end if |
|
|
|
|
|
else { |
|
|
|
|
|
TextFieldAusgabe1.setText("Der Spieler 1 ist dran."); |
|
|
|
|
|
spielerIstDran = 1; |
|
|
|
|
|
}//end else |
|
|
|
|
|
}//end else if |
|
|
|
|
|
else { |
|
|
|
|
|
TextFieldAusgabe1.setText("Huiuiuiui, ein Fehler!."); |
|
|
|
|
|
}//end else |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
}//end |
|
|
}//end |
|
|
|
|
|
|
|
|
} |
|
|
} |