From 2aee8c516b916bb46569762a1399dff1b5ce7a0a Mon Sep 17 00:00:00 2001 From: Shivam Chaudhary Date: Thu, 9 Feb 2023 15:48:56 +0100 Subject: [PATCH] Refactoring: Remove useless code and update constant names --- src/currencyExchange.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/src/currencyExchange.c b/src/currencyExchange.c index b3dc39a..2a22334 100644 --- a/src/currencyExchange.c +++ b/src/currencyExchange.c @@ -1,25 +1,13 @@ #include "currencyExchange.h" -float toUSD(float euro) { - - float USD = euro * CURRENT_USD_RATE_OF_ONE_EURO; - - return USD; -} - -float toGBP(float euro) { - - float GBP = euro * CURRENT_GBP_RATE_OF_ONE_EURO; - - return GBP; -} - float convert(float euro, int newCurrencyCode) { switch(newCurrencyCode) { - case 1: - return ( euro * CURRENT_USD_RATE_OF_ONE_EURO ); - case 2: - return ( euro * CURRENT_GBP_RATE_OF_ONE_EURO ); + case CURRENCY_CODE_USD: + return ( euro * USD_RATE_OF_ONE_EURO ); + + case CURRENCY_CODE_GBP: + return ( euro * GBP_RATE_OF_ONE_EURO ); } + return -1; } \ No newline at end of file