diff --git a/src/c/funktionen.c b/src/c/funktionen.c index d3c77a8..07470bf 100644 --- a/src/c/funktionen.c +++ b/src/c/funktionen.c @@ -21,32 +21,6 @@ int choose_program() { return choice; } -int addThreeNumbers(int num1, int num2, int num3) { - return num1 + num2 + num3; -} - -int multiply(int num1, int num2) { - return num1 * num2; -} - -int subtract(int num1, int num2) { - return num1 - num2; -} - -int divide(int num1, int num2) { - return num1 / num2; -} - -int power(int base, int power) { - int speicher = 1; - - for (int i = 0; i < power; i++) { - speicher *= base; - } - - return speicher; -} - int x_wins_00_10_20(char board[][3]) { if (board[0][0] == 'X' && board[1][0] == 'X' && board[2][0] == 'X') { return 1; @@ -95,6 +69,12 @@ int x_wins_02_11_20(char board[][3]) { } } +int o_wins_00_10_20(char board[][3]) { + if (board[0][0] == 'O' && board[1][0] == 'O' && board[2][0] == 'O') { + return 1; + } +} + int stringCharacterCounter(char string[]) { int stringLength = 0; @@ -117,12 +97,30 @@ int characterAppearanceInString(char c, char string[]) { return appear; } -int calculateCurrent(int voltage, int resistance) { - return voltage / resistance; +int addThreeNumbers(int num1, int num2, int num3) { + return num1 + num2 + num3; } -int calculatePressure(int force, int area) { - return force / area; +int multiply(int num1, int num2) { + return num1 * num2; +} + +int subtract(int num1, int num2) { + return num1 - num2; +} + +int divide(int num1, int num2) { + return num1 / num2; +} + +int power(int base, int power) { + int speicher = 1; + + for (int i = 0; i < power; i++) { + speicher *= base; + } + + return speicher; } // Function to calculate the sine of an angle in radians @@ -329,10 +327,14 @@ float remainderValue(float x, float y) { return fmod(x, y); } -float f(float m) { - return m * 9.81; -} - float calculateWeight(float mass) { return mass * 9.81; +} + +int calculateCurrent(int voltage, int resistance) { + return voltage / resistance; +} + +int calculatePressure(int force, int area) { + return force / area; } \ No newline at end of file diff --git a/src/c/funktionen.h b/src/c/funktionen.h index 050ff6e..9674e0a 100644 --- a/src/c/funktionen.h +++ b/src/c/funktionen.h @@ -35,6 +35,9 @@ 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 o_wins_00_10_20(char board[][3]); +// prüft, ob O bei Index 00, 10, 20 ist. + int x_wins_10_11_12(char board[][3]); //prüft, ob X bei Index 10, 11, 12 ist diff --git a/src/test/test_funktionen.c b/src/test/test_funktionen.c index 3b70910..439b5ab 100644 --- a/src/test/test_funktionen.c +++ b/src/test/test_funktionen.c @@ -215,16 +215,16 @@ void test_x_wins_onIndex_00_01_02(void) TEST_ASSERT_EQUAL_INT(expected, actual); } -void test_x_wins_onIndex_10_11_12(void) +void test_o_wins_onIndex_00_10_20(void) { /* arrange */ int actual; int expected = 1; - char board[][3] = {{' ',' ',' '}, {'X','X','X'}, {' ',' ',' '}}; + char board[][3] = {{'O',' ',' '}, {'O',' ',' '}, {'O',' ',' '}}; /* act */ - actual = x_wins_10_11_12(board); + actual = o_wins_00_10_20(board); /* assert */ TEST_ASSERT_EQUAL_INT(expected, actual);