diff --git a/src/c/funktionen.c b/src/c/funktionen.c index 8a5efbe..d3c77a8 100644 --- a/src/c/funktionen.c +++ b/src/c/funktionen.c @@ -6,27 +6,27 @@ void welcome() { - char x[15]; + char username[15]; printf("Hallo! Wie heisst du?\n"); - scanf("%s", &x); - printf("\nSchöner Name, %s!\n\n", x); + scanf("%s", &username); + printf("\nSchöner Name, %s!\n\n", username); } int choose_program() { - int i; + int choice; - printf("Welches der folgenden Programme moechtest du starten?\n1. Rechner.exe\n2. Gleichungen.exe\n3. TicTacToe.exe\n\n"); - scanf("%d", &i); + printf("Welches der folgenden Programme moechtest du starten?\n1. Rechner.exe\n2. Gleichungen.exe\n3. TicTacToe.exe\n4. Strings.exe\n\n"); + scanf("%d", &choice); - return i; + return choice; } -int addThreeNumbers(int a, int b, int c) { - return a + b + c; +int addThreeNumbers(int num1, int num2, int num3) { + return num1 + num2 + num3; } -int multiply(int h, int g) { - return h * g; +int multiply(int num1, int num2) { + return num1 * num2; } int subtract(int num1, int num2) { @@ -95,7 +95,7 @@ int x_wins_02_11_20(char board[][3]) { } } -int string_character_counter(char string[]) { +int stringCharacterCounter(char string[]) { int stringLength = 0; for (int i = 0; string[i] != '\0'; i++) { @@ -108,7 +108,7 @@ int string_character_counter(char string[]) { int characterAppearanceInString(char c, char string[]) { int appear = 0; - for (int i = 0; i < string_character_counter(string); i++) { + for (int i = 0; i < stringCharacterCounter(string); i++) { if (string[i] == c) { appear++; } @@ -117,12 +117,12 @@ int characterAppearanceInString(char c, char string[]) { return appear; } -int i(int v, int r) { - return v / r; +int calculateCurrent(int voltage, int resistance) { + return voltage / resistance; } -int p(int f, int a) { - return f / a; +int calculatePressure(int force, int area) { + return force / area; } // Function to calculate the sine of an angle in radians @@ -331,4 +331,8 @@ float remainderValue(float x, float y) { float f(float m) { return m * 9.81; +} + +float calculateWeight(float mass) { + return mass * 9.81; } \ No newline at end of file diff --git a/src/c/funktionen.h b/src/c/funktionen.h index 7cdc807..050ff6e 100644 --- a/src/c/funktionen.h +++ b/src/c/funktionen.h @@ -8,10 +8,10 @@ void welcome(); int choose_program(); // Die choose_program() Funktion laesst den User ein Programm auswaehlen. -int addThreeNumbers(int a, int b, int c); +int addThreeNumbers(int num1, int num2, int num3); // gibt die Addition von drei Zahlen zurück -int multiply(int h, int g); +int multiply(int num1, int num2); // gibt die Multiplikation von zwei Zahlen zurueck int subtract(int num1, int num2); @@ -47,16 +47,16 @@ int x_wins_00_11_22(char board[][3]); 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[]); +int stringCharacterCounter(char string[]); // liefert die Länge eines Strings zurück int characterAppearanceInString(char c, char string[]); // liefert die Anzahl an einem bestimmten Character in einem String zurueck -int i(int v, int r); +int calculateCurrent(int voltage, int resistance); // berechnet den Strom mithilfe ohmsches Gesetzes -int p(int f, int a); +int calculatePressure(int force, int area); // berechnet den Druck // Function to calculate the sine of an angle in radians @@ -151,7 +151,7 @@ float average(float x, float y); // Function to calculate the remainder of division between two numbers float remainderValue(float x, float y); -float f(float m); +float calculateWeight(float mass); // berechnet die Gewichtkraft #endif \ No newline at end of file diff --git a/src/test/test_funktionen.c b/src/test/test_funktionen.c index 4094322..3b70910 100644 --- a/src/test/test_funktionen.c +++ b/src/test/test_funktionen.c @@ -147,7 +147,9 @@ void test_2_toThePowerOf_7(void) int expected = 128; /* act */ - actual = power(2, 7); + int base = 2; + int exponent = 7; + actual = power(base, exponent); /* assert */ TEST_ASSERT_EQUAL_INT(expected, actual); @@ -282,7 +284,7 @@ void test_stringLaenge_von_Kokosnuss(void) char string[] = "Kokosnuss"; /* act */ - actual = string_character_counter(string); + actual = stringCharacterCounter(string); /* assert */ TEST_ASSERT_EQUAL_INT(expected, actual); @@ -311,9 +313,9 @@ void test_current_at_voltage12_resistance6(void) int expected = 2; /* act */ - int v = 12; - int r = 6; - actual = i(v, r); + int voltage = 12; + int resistance = 6; + actual = calculateCurrent(voltage, resistance); /* assert */ TEST_ASSERT_EQUAL_INT(expected, actual); @@ -326,9 +328,9 @@ void test_pressure_at_force360_area12(void) int expected = 30; /* act */ - int f = 360; - int a = 12; - actual = p(f, a); + int force = 360; + int area = 12; + actual = calculatePressure(force, area); /* assert */ TEST_ASSERT_EQUAL_INT(expected, actual); @@ -431,8 +433,8 @@ void test_weight_at_mass100(void) float expected = 981; /* act */; - float m = 100; - actual = f(m); + float mass = 100; + actual = calculateWeight(mass); /* assert */ TEST_ASSERT_EQUAL_FLOAT(expected, actual);