diff --git a/src/c/funktionen.c b/src/c/funktionen.c index a152ca0..1b33bb3 100644 --- a/src/c/funktionen.c +++ b/src/c/funktionen.c @@ -71,6 +71,30 @@ int x_wins_00_01_02(char board[][3]) { } } +int x_wins_10_11_12(char board[][3]) { + if (board[1][0] == 'X' && board[1][1] == 'X' && board[1][2] == 'X') { + return 1; + } +} + +int x_wins_20_21_22(char board[][3]) { + if (board[2][0] == 'X' && board[2][1] == 'X' && board[2][2] == 'X') { + return 1; + } +} + +int x_wins_00_11_22(char board[][3]) { + if (board[0][0] == 'X' && board[1][1] == 'X' && board[2][2] == 'X') { + return 1; + } +} + +int x_wins_02_11_20(char board[][3]) { + if (board[0][2] == 'X' && board[1][1] == 'X' && board[2][0] == 'X') { + return 1; + } +} + int string_character_counter(char string[]) { int stringLength = 0; diff --git a/src/c/funktionen.h b/src/c/funktionen.h index c1738db..5958b04 100644 --- a/src/c/funktionen.h +++ b/src/c/funktionen.h @@ -35,6 +35,18 @@ int x_wins_02_12_22(char board[][3]); int x_wins_00_01_02(char board[][3]); //prüft, ob X bei Index 00, 01, 02 ist +int x_wins_10_11_12(char board[][3]); +//prüft, ob X bei Index 10, 11, 12 ist + +int x_wins_20_21_22(char board[][3]); +// prüft, ob X bei Index 20, 21, 22 ist + +int x_wins_00_11_22(char board[][3]); +// prüft, ob X bei Index 00, 11, 22 ist + +int x_wins_02_11_20(char board[][3]); +// prüft, ob X bei Index 02, 11, 20 ist + int string_character_counter(char string[]); // liefert die Länge eines Strings zurück diff --git a/src/test/test_funktionen.c b/src/test/test_funktionen.c index 4ec8524..6f2966b 100644 --- a/src/test/test_funktionen.c +++ b/src/test/test_funktionen.c @@ -213,6 +213,66 @@ void test_x_wins_onIndex_00_01_02(void) TEST_ASSERT_EQUAL_INT(expected, actual); } +void test_x_wins_onIndex_10_11_12(void) +{ + /* arrange */ + int actual; + int expected = 1; + + char board[][3] = {{' ',' ',' '}, {'X','X','X'}, {' ',' ',' '}}; + + /* act */ + actual = x_wins_10_11_12(board); + + /* assert */ + TEST_ASSERT_EQUAL_INT(expected, actual); +} + +void test_x_wins_onIndex_20_21_22(void) +{ + /* arrange */ + int actual; + int expected = 1; + + char board[][3] = {{' ',' ',' '}, {' ',' ',' '}, {'X','X','X'}}; + + /* act */ + actual = x_wins_20_21_22(board); + + /* assert */ + TEST_ASSERT_EQUAL_INT(expected, actual); +} + +void test_x_wins_onIndex_00_11_22(void) +{ + /* arrange */ + int actual; + int expected = 1; + + char board[][3] = {{'X',' ',' '}, {' ','X',' '}, {' ',' ','X'}}; + + /* act */ + actual = x_wins_00_11_22(board); + + /* assert */ + TEST_ASSERT_EQUAL_INT(expected, actual); +} + +void test_x_wins_onIndex_02_11_20(void) +{ + /* arrange */ + int actual; + int expected = 1; + + char board[][3] = {{' ',' ','X'}, {' ','X',' '}, {'X',' ',' '}}; + + /* act */ + actual = x_wins_02_11_20(board); + + /* assert */ + TEST_ASSERT_EQUAL_INT(expected, actual); +} + void test_stringLaenge_von_Kokosnuss(void) { /* arrange */