diff --git a/src/sendmoney.c b/src/sendmoney.c index 930f954..0980976 100644 --- a/src/sendmoney.c +++ b/src/sendmoney.c @@ -14,14 +14,22 @@ bool sendMoney(int customerID){ if(recID>1000){ bool recExists=checkCustomerExists(recID); if(recExists){ - if(withdrawSpecificAmount(customerID, amountToSend)){ - if(depositSpecificAmount(recID, amountToSend)){ - printf("\nYou have successfuly transfered %.2f€ to [%d]",amountToSend,recID); - return true; + if(recID==customerID){ + printf("\nYou cannot send money to yourself. Aborting. \n"); + return false; + } + else{ + if(withdrawSpecificAmount(customerID, amountToSend)){ + if(depositSpecificAmount(recID, amountToSend)){ + printf("\nYou have successfuly transfered %.2f€ to [%d]",amountToSend,recID); + return true; + } + else{ + printf("\nSomething went wrong with the transfer. Please contact staff."); + } } - }else{ - printf("\nSomething went wrong with the transfer. Please contact staff."); } + }else{ if(withdrawSpecificAmount(customerID, amountToSend)){ printf("\nYou have successfuly transfered %.2f€ to [%d]",amountToSend,recID);