This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public MainWindow() | |
| { | |
| InitializeComponent(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace TicTacToe | |
| { | |
| class Player | |
| { | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public enum Player | |
| { | |
| None, | |
| Player1, | |
| Player2 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private List> fields = new List>() | |
| { | |
| new List() {Player.None, Player.None, Player.None}, | |
| new List() {Player.None, Player.None, Player.None}, | |
| new List() {Player.None, Player.None, Player.None}, | |
| }; | |
| private Player currentPlayer = Player.Player1; | |
| private bool gameActive = true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public MainWindow() | |
| { | |
| InitializeComponent(); | |
| GameInformation.Content = "X ist am Zug"; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private void Button_Click(object sender, EventArgs e) | |
| { | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var button = (Button)sender; | |
| int column = Grid.GetColumn(button); | |
| int row = Grid.GetRow(button); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private void Button_Click(object sender, EventArgs e) | |
| { | |
| var button = (Button)sender; | |
| int column = Grid.GetColumn(button); | |
| int row = Grid.GetRow(button); | |
| if (gameActive && fields[column][row] == Player.None) | |
| { | |
| var currentSymbol = ""; | |
| if (currentPlayer == Player.Player1) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <Button Click="Button_Click" Name="Button0_0" Grid.Column="0" Grid.Row="0" Style="{StaticResource CellStyle}" /> | |
| <Button Click="Button_Click" Name="Button0_1" Grid.Column="0" Grid.Row="1" Style="{StaticResource CellStyle}" /> | |
| <Button Click="Button_Click" Name="Button0_2" Grid.Column="0" Grid.Row="2" Style="{StaticResource CellStyle}" /> | |
| ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private bool CheckForWinner() | |
| { | |
| // Check rows | |
| foreach (List row in fields) | |
| { | |
| if (row[0] != Player.None && row[0] == row[1] && row[1] == row[2]) | |
| { | |
| return true; | |
| } | |
| } |
OlderNewer