Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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.");
        }
Ejemplo n.º 4
0
 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();
 }
Ejemplo n.º 5
0
 public static void printBalance(Account account)
 {
     Console.WriteLine("Account ID: {0} Account balance: {1}", account.ID, account.GetBalance());
 }
Ejemplo n.º 6
0
 public override void Handle(Account acc)
 {
     acc.SetBalance(acc.GetBalance() + 10);
 }