public void Withdraw(int amount) { if (account.GetBalance() >= amount) { account.Withdraw(amount); } else { int difference = amount - account.GetBalance(); account.Withdraw(account.GetBalance()); this.SetDebtBalance(this.GetDebtBalance() + difference); } }
public Boolean execute(Account acc, Bank bank, int amount) { if (amount > (acc.GetBalance() * 0.3)) { return(false); } else if (amount <= 0) { throw new System.ArgumentException("Invalid requested amount."); } else { acc.SetBalance(acc.GetBalance() + amount); bank.AvailableLoan = bank.AvailableLoan - amount; return(true); } }
//public Transaction() : base (OperationType.Type type , string desc) //{ // super(type, desc); // this.transferAmount = amount; //} public void execute(Account sender, Account receiver, int amount) { if (amount > sender.GetBalance()) { throw new System.ArgumentException("Not enough balance."); } else if (amount <= 0) { throw new System.ArgumentException("Negative amount to transfer."); } sender.SetBalance(sender.GetBalance() - amount); receiver.SetBalance(receiver.GetBalance() + amount); //sender.balance = sender.balance - amount; //receiver.balance = receiver.balance + amount; Console.WriteLine("Amount transferred."); }
public void Print(Account account) { Console.WriteLine("Dane Konta: {0}", account.AccountNumber); Console.WriteLine("Typ: {0}", account.TypeName()); Console.WriteLine("Saldo: {0}", account.GetBalance()); Console.WriteLine("Imie i nazwisko właściciela: {0}", account.GetFullName()); Console.WriteLine("PESEL: {0}", account.Pesel); Console.WriteLine(); }
public static void printBalance(Account account) { Console.WriteLine("Account ID: {0} Account balance: {1}", account.ID, account.GetBalance()); }
public override void Handle(Account acc) { acc.SetBalance(acc.GetBalance() + 10); }