Browse Source

Konflikte gelöst

remotes/origin/siamak
Siamak 11 months ago
parent
commit
1859dee16e
  1. 82
      src/c/funktionen.c
  2. 13
      src/c/funktionen.h
  3. 22
      src/test/test_funktionen.c
  4. 1
      team.md

82
src/c/funktionen.c

@ -6,45 +6,19 @@
void welcome() { void welcome() {
char x[15];
char username[15];
printf("Hallo! Wie heisst du?\n"); 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 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]) { 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; int stringLength = 0;
for (int i = 0; string[i] != '\0'; i++) { 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 characterAppearanceInString(char c, char string[]) {
int appear = 0; 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) { if (string[i] == c) {
appear++; appear++;
} }
@ -135,12 +109,30 @@ int characterAppearanceInString(char c, char string[]) {
return appear; 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 // Function to calculate the sine of an angle in radians
@ -347,6 +339,14 @@ float remainderValue(float x, float y) {
return fmod(x, 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;
} }

13
src/c/funktionen.h

@ -8,10 +8,10 @@ void welcome();
int choose_program(); int choose_program();
// Die choose_program() Funktion laesst den User ein Programm auswaehlen. // 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 // 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 // gibt die Multiplikation von zwei Zahlen zurueck
int subtract(int num1, int num2); 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. // prüft, ob O bei Index 02, 12, 22 ist.
int string_character_counter(char string[]); int string_character_counter(char string[]);
int stringCharacterCounter(char string[]);
// liefert die Länge eines Strings zurück // liefert die Länge eines Strings zurück
int characterAppearanceInString(char c, char string[]); int characterAppearanceInString(char c, char string[]);
// liefert die Anzahl an einem bestimmten Character in einem String zurueck // 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 // berechnet den Strom mithilfe ohmsches Gesetzes
int p(int f, int a);
int calculatePressure(int force, int area);
// berechnet den Druck // berechnet den Druck
// Function to calculate the sine of an angle in radians // 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 // Function to calculate the remainder of division between two numbers
float remainderValue(float x, float y); float remainderValue(float x, float y);
float f(float m);
float calculateWeight(float mass);
// berechnet die Gewichtkraft // berechnet die Gewichtkraft
#endif #endif

22
src/test/test_funktionen.c

@ -147,7 +147,9 @@ void test_2_toThePowerOf_7(void)
int expected = 128; int expected = 128;
/* act */ /* act */
actual = power(2, 7);
int base = 2;
int exponent = 7;
actual = power(base, exponent);
/* assert */ /* assert */
TEST_ASSERT_EQUAL_INT(expected, actual); TEST_ASSERT_EQUAL_INT(expected, actual);
@ -327,7 +329,7 @@ void test_stringLaenge_von_Kokosnuss(void)
char string[] = "Kokosnuss"; char string[] = "Kokosnuss";
/* act */ /* act */
actual = string_character_counter(string);
actual = stringCharacterCounter(string);
/* assert */ /* assert */
TEST_ASSERT_EQUAL_INT(expected, actual); TEST_ASSERT_EQUAL_INT(expected, actual);
@ -356,9 +358,9 @@ void test_current_at_voltage12_resistance6(void)
int expected = 2; int expected = 2;
/* act */ /* act */
int v = 12;
int r = 6;
actual = i(v, r);
int voltage = 12;
int resistance = 6;
actual = calculateCurrent(voltage, resistance);
/* assert */ /* assert */
TEST_ASSERT_EQUAL_INT(expected, actual); TEST_ASSERT_EQUAL_INT(expected, actual);
@ -371,9 +373,9 @@ void test_pressure_at_force360_area12(void)
int expected = 30; int expected = 30;
/* act */ /* act */
int f = 360;
int a = 12;
actual = p(f, a);
int force = 360;
int area = 12;
actual = calculatePressure(force, area);
/* assert */ /* assert */
TEST_ASSERT_EQUAL_INT(expected, actual); TEST_ASSERT_EQUAL_INT(expected, actual);
@ -476,8 +478,8 @@ void test_weight_at_mass100(void)
float expected = 981; float expected = 981;
/* act */; /* act */;
float m = 100;
actual = f(m);
float mass = 100;
actual = calculateWeight(mass);
/* assert */ /* assert */
TEST_ASSERT_EQUAL_FLOAT(expected, actual); TEST_ASSERT_EQUAL_FLOAT(expected, actual);

1
team.md

@ -1,3 +1,4 @@
- COMMITER-NAME, FD-NUMMER
- Habib, fdai8062 - Habib, fdai8062
- Abdelrahman, fdai7981 - Abdelrahman, fdai7981
- Siamak, fdai6496 - Siamak, fdai6496
Loading…
Cancel
Save