Wrox.ProCSharp.JupiterBank.GoldAccount.Withdraw C# (CSharp) Method

Withdraw() public method

public Withdraw ( decimal amount ) : bool
amount decimal
return bool
        public bool Withdraw(decimal amount)
        {
            if (_balance >= amount)
            {
                _balance -= amount;
                return true;
            }
            WriteLine("Withdrawal attempt failed.");
            return false;
        }

Usage Example

        static void Main()
        {
            IBankAccount venusAccount = new SaverAccount();
            IBankAccount jupiterAccount = new GoldAccount();

            venusAccount.PayIn(200);
            venusAccount.Withdraw(100);
            WriteLine(venusAccount.ToString());

            jupiterAccount.PayIn(500);
            jupiterAccount.Withdraw(600);
            jupiterAccount.Withdraw(100);
            WriteLine(jupiterAccount.ToString());
        }
All Usage Examples Of Wrox.ProCSharp.JupiterBank.GoldAccount::Withdraw