Browse Source

Konflikt gelöst

remotes/origin/siamak
Habib 11 months ago
parent
commit
7c37e77d15
  1. 70
      src/c/funktionen.c
  2. 3
      src/c/funktionen.h
  3. 6
      src/test/test_funktionen.c

70
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;
}

3
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

6
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);

Loading…
Cancel
Save