static void Main(string[] args) { var savingsAccount = new SavingsAccount(owner: "Joe Decker", balance: 200); savingsAccount.ShowAccountDetails(); savingsAccount.Withdraw(20); savingsAccount.CheckRemainingBalance(); savingsAccount.Deposit(100); savingsAccount.CheckRemainingBalance(); var loanAccount = new LoanAccount(owner: "John Wright", balance: -1200); loanAccount.ShowAccountDetails(); loanAccount.Deposit(200); loanAccount.CheckRemainingBalance(); var investmentAccount = new InvestmentAccount(owner: "Mike Schwartz", balance: 10000); investmentAccount.ShowAccountDetails(); investmentAccount.Withdraw(2000); investmentAccount.CheckRemainingBalance(); investmentAccount.Deposit(1200); investmentAccount.CheckRemainingBalance(); }
public static void RunExample() { ShortTermAccountFactory shortTermAccountFactory = new ShortTermAccountFactory(); AbstractAccountFactory abstractAccountFactory = new AbstractAccountFactory(shortTermAccountFactory, "Brian"); BankAccount checkingAccount = abstractAccountFactory.BankAccount; InvestmentAccount investmentAccount = abstractAccountFactory.InvestmentAccount; checkingAccount.Deposit(100); investmentAccount.Deposit(100); }
public void Deposit_GivenInvalidAmount_ShouldThrowException() { // Arrange double startingBalance = 200; double negativeAmount = -100; var investmentAccount = new InvestmentAccount(owner: "Mike Schwartz", balance: startingBalance); // Act, Assert Assert.Throws <ArgumentOutOfRangeException>(() => investmentAccount.Deposit(negativeAmount)); }
public void DepositWithValidAmountInvestment() { float initialBalance = 200; float depositAmount = 50; float expected = 250; Customer customer = new Customer(4, "Allen", "02222222"); InvestmentAccount investmentAccount = new InvestmentAccount(customer, 5, initialBalance, 5, 20); float actual = investmentAccount.Deposit(depositAmount); Assert.AreEqual(expected, actual); }
private void btnTotal_Click(object sender, EventArgs e) { SavingsAccount sa = new SavingsAccount(); InvestmentAccount ic = new InvestmentAccount(); sa.Deposit(200.0); ic.Deposit(300.0); TaxManager t = new TaxManager(); t.Accumulates(sa); t.Accumulates(ic); MessageBox.Show("Total de taxas: " + t.Total); }
public void Deposit_GivenValidAmount_ShouldUpdateBalance() { // Arrange double startingBalance = 1000; double depositAmount = 1200; double expected = startingBalance + depositAmount; var investmentAccount = new InvestmentAccount(owner: "Mike Schwartz", balance: startingBalance); // Act investmentAccount.Deposit(depositAmount); // Assert double actual = investmentAccount.Balance; Assert.Equal(expected, actual); }
//tests deposit function with a invaild amount public void DepositWithInvalidAmountInvestment() { float initialBalance = 200; float depositAmount = -50; Customer customer = new Customer(4, "Allen", "02222222"); InvestmentAccount investmentAccount = new InvestmentAccount(customer, 5, initialBalance, 5, 20); try { investmentAccount.Deposit(depositAmount); } catch (ArgumentOutOfRangeException) { return; } Assert.Fail(); }