diff --git a/src/_file_information.h b/src/_file_information.h index c843f2b..9b919c4 100644 --- a/src/_file_information.h +++ b/src/_file_information.h @@ -1,2 +1,2 @@ #define MAX_LENGTH 200 -#define CUSTOMER_DATA_FILE "CustomerData.txt" \ No newline at end of file +#define CUSTOMER_DATA_FILE "src/CustomerData.txt" \ No newline at end of file diff --git a/src/currentCustomerAccountBalance.c b/src/currentCustomerAccountBalance.c index a91e306..d306175 100644 --- a/src/currentCustomerAccountBalance.c +++ b/src/currentCustomerAccountBalance.c @@ -1,4 +1,5 @@ #include "currentCustomerAccountBalance.h" +#include "_file_information.h" float fetchBalanceFromBalanceString(char balance_String[MAX_LENGTH]) { float balance = 0; diff --git a/src/currentCustomerAccountBalance.h b/src/currentCustomerAccountBalance.h index 772b191..dc39493 100644 --- a/src/currentCustomerAccountBalance.h +++ b/src/currentCustomerAccountBalance.h @@ -1,3 +1,7 @@ +#ifndef CURRENTCUSTOMERACCOUNTBALANCE_H_ +#define CURRENTCUSTOMERACCOUNTBALANCE_H_ + + #include #include #include @@ -8,3 +12,5 @@ float getAvailableAccountBalance(int user_id); float fetchBalanceFromBalanceString(char balance_String[MAX_LENGTH]); float readFileAndGetAvailableBalance(FILE *file, char stringID[MAX_LENGTH]); + +#endif \ No newline at end of file diff --git a/src/depositMoney.c b/src/depositMoney.c index 869b1c6..99cd553 100644 --- a/src/depositMoney.c +++ b/src/depositMoney.c @@ -1,5 +1,6 @@ #include "depositMoney.h" -#include "updateCustomerAccountBalance.c" +#include "updateCustomerAccountBalance.h" +#include "currentCustomerAccountBalance.h" void askToTryAgain(bool afterError, int customerID){ char choice; @@ -51,9 +52,24 @@ bool depositMoney(int customerID){ return false; } +bool depositSpecificAmount(int customerID, float amount){ + + float availableAccountBalance=getAvailableAccountBalance(customerID); + + if(amount>0){ + if(updateAvailableAccountBalance(customerID, availableAccountBalance+amount)){ + return true; + }else{ + return false; + } + } + return false; +} + /* int main(){ - depositMoney(1234); + depositSpecificAmount(1234,5000); + //depositMoney(1234); return 0; } */ \ No newline at end of file diff --git a/src/depositMoney.h b/src/depositMoney.h index 82961dc..4661e00 100644 --- a/src/depositMoney.h +++ b/src/depositMoney.h @@ -1,3 +1,5 @@ + + #include #include "CustomerProperties.h" #include @@ -6,3 +8,4 @@ bool depositMoney(int customerID); void askToTryAgain(bool afterError, int customerID); +bool depositSpecificAmount(int customerID, float amount); \ No newline at end of file diff --git a/src/updateCustomerAccountBalance.h b/src/updateCustomerAccountBalance.h index 6078784..9a931b3 100644 --- a/src/updateCustomerAccountBalance.h +++ b/src/updateCustomerAccountBalance.h @@ -1,3 +1,6 @@ +#ifndef UPDATECUSTOMERACCOUNTBALANCE_H_ +#define UPDATECUSTOMERACCOUNTBALANCE_H_ + #include #include #include @@ -8,3 +11,5 @@ bool updateAvailableAccountBalance(int user_id, float newBalance); void replaceBalanceInString(float replacementBalance, int currentLine); + +#endif \ No newline at end of file diff --git a/tests/test_LoginCustomer.c b/tests/test_LoginCustomer.c deleted file mode 100644 index 610a847..0000000 --- a/tests/test_LoginCustomer.c +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include "LoginCustomer.h" -void setUp(){}; -void tearDown(){}; -void test_checkLogin() -{ - /*arrange*/ - bool expected_test_values_compute_to_true[] = {4==4,true==true, 1==1, false==false, 'z'=='z', '='=='=',0x1A==0x1A}; - int length_1 = sizeof(expected_test_values_compute_to_true)/sizeof(bool); - - bool expected_test_values_compute_to_false[] = {4!=4,true==false,1==0,false==true,'z'=='x','!'==')',0x1A==0x2B}; - int length_2 = sizeof(expected_test_values_compute_to_false)/sizeof(bool); - - /*act and assertions*/ - for(int i=0;i<7;++i) { - TEST_ASSERT_TRUE(checkLogin(expected_test_values_compute_to_true[i])); - } - for(int i=0;i<7;++i){ - TEST_ASSERT_FALSE(checkLogin(expected_test_values_compute_to_false[i])); - } -} diff --git a/tests/test_mainMenu.c b/tests/test_mainMenu.c deleted file mode 100644 index be1fb40..0000000 --- a/tests/test_mainMenu.c +++ /dev/null @@ -1,145 +0,0 @@ -#ifdef TEST - -#include "unity.h" - -#include "mainMenu.h" - -void setUp(void) -{ -} - -void tearDown(void) -{ -} - -void test_agePermissionValidAge(void) -{ - //Test case : 0 - - //Arrange - - int validAge[83]; - - bool validAgeResult[83]; - - int j=0; - - for(int i =18;i<101;i++){ - - validAge[j]= i; - j++; - } - - //Act - - for(int i=0;i<83;i++){ - - validAgeResult[i] = agePermission(validAge[i]); - } - - //Assert - - for(int i=0;i<83;i++){ - - TEST_ASSERT_TRUE(validAgeResult[i]); - - } - -} - -void test_agePermissionInvalidAge(void) -{ - - //Test case : 1 - - //Arrange - - int invalidAge[117]; - - bool invalidAgeResult[117]; - - int j=0; - - for(int i =-100;i<18;i++){ - - invalidAge[j]= i; - j++; - } - - //Act - - for(int i=0;i<117;i++){ - - invalidAgeResult[i] = agePermission(invalidAge[i]); - - } - - //Assert - - for(int i=0;i<117;i++){ - - TEST_ASSERT_FALSE(invalidAgeResult[i]); - - } - -} - -void test_IsInteger(void) -{ - - //Arrange - - char* inputIsInteger[] = {"-10000000","-2000000","-354698","-66667","-7878","-987","-64","-5","0","1","2","10","201","333","4321","56974","698751","7878989","88954621" }; - - bool inputIsIntegerResult[19]; - - //Act - - for(int i=0;i<19;i++) - { - - inputIsIntegerResult[i] = checkIfInteger(inputIsInteger[i]); - - } - - //Assert - - for(int i=0;i<19;i++) - { - - TEST_ASSERT_TRUE(inputIsIntegerResult[i]); - - } - -} - -void test_IsNotInteger(void) -{ - - //Arrange - - char* inputIsNotInteger[] = {"0.15","3.141592653589793238","5.3254f","-6.264","-7878.3261","foo","Bar","FIZZ","buzZ","joHN","jAnE","foo-bar","3,15","2k13",""," ","-","+","/*-+.,/=" }; - - bool inputIsNotIntegerResult[19]; - - //Act - - for(int i=0;i<19;i++) - { - - inputIsNotIntegerResult[i] = checkIfInteger(inputIsNotInteger[i]); - - } - - //Assert - - for(int i=0;i<19;i++) - { - - TEST_ASSERT_FALSE(inputIsNotIntegerResult[i]); - - } - -} - -#endif // TEST