diff --git a/src/c/funktionen.c b/src/c/funktionen.c index ac688cd..3f3f3c4 100644 --- a/src/c/funktionen.c +++ b/src/c/funktionen.c @@ -6,45 +6,19 @@ 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; -} - -int addThreeNumbers(int a, int b, int c) { - return a + b + c; -} - -int multiply(int h, int g) { - return h * g; -} - -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; + return choice; } int x_wins_00_10_20(char board[][3]) { @@ -113,7 +87,7 @@ int o_wins_02_12_22(char board[][3]) { } } -int string_character_counter(char string[]) { +int stringCharacterCounter(char string[]) { int stringLength = 0; for (int i = 0; string[i] != '\0'; i++) { @@ -126,7 +100,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++; } @@ -135,12 +109,30 @@ int characterAppearanceInString(char c, char string[]) { return appear; } -int i(int v, int r) { - return v / r; +int addThreeNumbers(int num1, int num2, int num3) { + return num1 + num2 + num3; } -int p(int f, int a) { - return f / a; +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 @@ -347,6 +339,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 e58cb33..185b4a1 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); @@ -57,15 +57,18 @@ int o_wins_02_12_22(char board[][3]) // prüft, ob O bei Index 02, 12, 22 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 @@ -160,7 +163,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 71a510b..719bc23 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); @@ -327,7 +329,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); @@ -356,9 +358,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); @@ -371,9 +373,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); @@ -476,8 +478,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); diff --git a/team.md b/team.md index 0628913..493fc4c 100644 --- a/team.md +++ b/team.md @@ -1,3 +1,4 @@ +- COMMITER-NAME, FD-NUMMER - Habib, fdai8062 - Abdelrahman, fdai7981 - Siamak, fdai6496