示例#1
0
 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);
     }
 }
示例#2
0
 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);
     }
 }
示例#3
0
        //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.");
        }
示例#4
0
文件: Printer.cs 项目: osek90/bank
 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();
 }
示例#5
0
文件: Program.cs 项目: lukeses/bank
 public static void printBalance(Account account)
 {
     Console.WriteLine("Account ID: {0} Account balance: {1}", account.ID, account.GetBalance());
 }
示例#6
0
 public override void Handle(Account acc)
 {
     acc.SetBalance(acc.GetBalance() + 10);
 }