Browse Source

added logic to ConTime and Unittest for the function

remotes/origin/feature
Enrico Schellenberger 11 months ago
parent
commit
5b985d772d
  1. 21
      src/main/c/ConvertMode.c
  2. 43
      src/main/c/main_taschenrechner.c
  3. 2
      src/main/c/taschenrechner.h
  4. 4
      src/test/c/test_taschenrechner.c

21
src/main/c/ConvertMode.c

@ -188,6 +188,18 @@ double getValue(int choice) {
printf("\nThe convertet result is %dlf %d³", result, Distance[endingUnit]);
break;
case 13:
printf("\nEnter what the Unit is starting with (0 (24h), 1 (12h)): ");
scanf("%d", &startingUnit);
printf("\nEnter what the value should it be changed to (0 (24h), 1 (12h)): ");
scanf("%d", &endingUnit);
result = ConArea(value, startingUnit, endingUnit);
printf("\nThe convertet result is %dlf %d", result, Distance[endingUnit]);
break;
}
}
}
@ -233,11 +245,6 @@ double ConSpeed(double speed, int startingUnit, int endingUnit) {
double ConTime() {
}
double ConClock() {
}
@ -254,7 +261,7 @@ void unitConverterMode() {
printf("Weight conversion:\n");
printf("4. Convert Gram (mg, g, kg)\n");
printf("5. Gram to Pounds \n")
printf("5. Gram to Pounds \n");
printf("Temprature conversion:\n");
printf("6. Celsius to Fahrenheit\n");
@ -274,7 +281,7 @@ void unitConverterMode() {
printf("12. Convert Volume (cm³, m³, km³)\n");
printf("Time conversion \n");
printf("13. Convert time (s, m, h) \n");
printf("13. Convert time (s, m, h, d, w, m, y) \n");
printf("14. Convert Clock (12 Hour, 24 Hour) \n");
printf("Time conversion \n");

43
src/main/c/main_taschenrechner.c

@ -948,6 +948,49 @@ double ConVolume(double volum, int startingUnit, int endingUnit) {
break;
}
}
double ConTime(double time, int startingUnit, int endingUnit) {
switch (startingUnit)
{
case 0: //24 to x
switch (endingUnit)
{
case 0: //24 to 24
return time;
break;
case 1: //24 to 12
if (time > 12) {
return time -12;
}
else {
return time
}
break;
default:
break;
}
case 1: //12 to x
switch (endingUnit)
{
case 0: //12 to 24
return time + 12;
break;
case 1: //12 to 12
return time;
break;
default:
break;
}
default:
break;
}
}
//..

2
src/main/c/taschenrechner.h

@ -81,4 +81,6 @@ double ConArea(double area, int startingUnit, int endingUnit);
double ConVolume(double volum, int startingUnit, int endingUnit);
double ConTime(double time, int startingUnit, int endingUnit);
#endif // TASCHENRECHNER_H

4
src/test/c/test_taschenrechner.c

@ -98,6 +98,10 @@ void test_ConVolume(void) {//5 mm to cm
TEST_ASSERT_EQUAL(0.005), result);
}
void test_ConTime(void) {//5:00 to 5AM
double result = ConData(5, 0, 1);
TEST_ASSERT_EQUAL(5), result);
}

Loading…
Cancel
Save