static void Main(string[] args) { Account account = new Account("Ramona Mihai", 1500); account.ActivateAccount(); Console.WriteLine($"The account holder is: {account.Name}."); Console.WriteLine($"Your amount: {account.Money} Euros."); account.DepositMoney(118); Console.WriteLine($"Your total amount now is: {account.Money}."); account.Withdrawals(320); Console.WriteLine($"Your total amount after withdrawl is: {account.Money}."); account.Withdrawals(2015); Console.WriteLine("--------------------"); Account sourceAccount = new Account("Ramona Mihai", 350); Account destinationAccount = new Account("Roxana", 128); destinationAccount.ActivateAccount(); sourceAccount.ActivateAccount(); Bank.TransferMoney(sourceAccount, destinationAccount, 200); Console.WriteLine("-------------------"); }
/// <summary> /// Withdraw money from balance and change bonus points /// </summary> /// <param name="account">Account</param> /// <param name="amount">Amount</param> /// <returns>Operation successfully completed</returns> public bool Deposit(Account account, decimal amount) { if (account.IsEnabled) { account.DepositMoney(amount); account.AccountType.ChangeBonus(amount, account.Balance); return(true); } return(false); }
public bool TransferMoney(uint accountFromId, uint accountToId, ulong amount) { Account fromAccount = Accounts.FirstOrDefault(x => x.GetID() == accountFromId); Account toAccount = Accounts.FirstOrDefault(x => x.GetID() == accountToId); if (fromAccount.GetBalance() < amount) { return(false); } fromAccount.WithdrawMoney(amount); toAccount.DepositMoney(amount); return(true); }
public static void TransferMoney(Account sourceAccount, Account destinationAccount, decimal amount) { if (sourceAccount.IsActive && destinationAccount.IsActive) { if (sourceAccount.TotalAmount >= amount) { sourceAccount.Withdrawals(amount); destinationAccount.DepositMoney(amount); Console.WriteLine("The transaction was successful!"); } else { Console.WriteLine("Sorry, you don't have enough money for the transaction!"); } } else { Console.WriteLine("One of the accounts is not active!"); } }