diff --git a/src/main/c/ConvertMode.c b/src/main/c/ConvertMode.c index 080f0aa..acf9158 100644 --- a/src/main/c/ConvertMode.c +++ b/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"); diff --git a/src/main/c/main_taschenrechner.c b/src/main/c/main_taschenrechner.c index e0b225b..cbd4e1b 100644 --- a/src/main/c/main_taschenrechner.c +++ b/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; + } +} //.. diff --git a/src/main/c/taschenrechner.h b/src/main/c/taschenrechner.h index c575997..f5a8302 100644 --- a/src/main/c/taschenrechner.h +++ b/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 diff --git a/src/test/c/test_taschenrechner.c b/src/test/c/test_taschenrechner.c index 283f097..60b744d 100644 --- a/src/test/c/test_taschenrechner.c +++ b/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); +}