static void Main(string[] args) { var giftCard = new GiftCardAccount("gift card", 100, 50); giftCard.MakeWithdrawal(20, DateTime.Now, "get expensive coffee"); giftCard.MakeWithdrawal(50, DateTime.Now, "buy groceries"); giftCard.PerformMonthEndTransactions(); // can make additional deposits: giftCard.MakeDeposit(27.50m, DateTime.Now, "add some additional spending money"); Console.WriteLine(giftCard.GetAccountHistory()); var savings = new InterestEarningAccount("savings account", 10000); savings.MakeDeposit(750, DateTime.Now, "save some money"); savings.MakeDeposit(1250, DateTime.Now, "Add more savings"); savings.MakeWithdrawal(250, DateTime.Now, "Needed to pay monthly bills"); savings.PerformMonthEndTransactions(); Console.WriteLine(savings.GetAccountHistory()); var lineOfCredit = new LineOfCreditAccount("line of credit", 0, 10000); // How much is too much to borrow? lineOfCredit.MakeWithdrawal(1000m, DateTime.Now, "Take out monthly advance"); lineOfCredit.MakeDeposit(50m, DateTime.Now, "Pay back small amount"); lineOfCredit.MakeWithdrawal(5000m, DateTime.Now, "Emergency funds for repairs"); lineOfCredit.MakeDeposit(150m, DateTime.Now, "Partial restoration on repairs"); lineOfCredit.PerformMonthEndTransactions(); Console.WriteLine(lineOfCredit.GetAccountHistory()); }
static void Main(string[] args) { var account = new BankAccount("Пашка", 1001); Console.WriteLine($"Account {account.Number} was created for {account.Owner} with {account.Balance} initial balance."); account.MakeWithdrawal(500, DateTime.Now, "Rent payment"); Console.WriteLine(account.Balance); account.MakeDeposit(100, DateTime.Now, "Friend paid me back"); Console.WriteLine(account.Balance); /* try * { * var invalidAccount = new BankAccount("invalid", -55); * } * catch (ArgumentOutOfRangeException e) * { * Console.WriteLine("Exception caught creating account with negative balance"); * Console.WriteLine(e.ToString()); * } * * // Test for a negative balance. * try * { * account.MakeWithdrawal(750, DateTime.Now, "Attempt to overdraw"); * } * catch (InvalidOperationException e) * { * Console.WriteLine("Exception caught trying to overdraw"); * Console.WriteLine(e.ToString()); * } */ Console.WriteLine(account.GetAccountHistory()); var giftCard = new GiftCardAccount("gift card", 100, 50); giftCard.MakeWithdrawal(20, DateTime.Now, "get expensive coffee"); giftCard.MakeWithdrawal(50, DateTime.Now, "buy groceries"); giftCard.PerformMonthEndTransactions(); // can make additional deposits: giftCard.MakeDeposit(27.50m, DateTime.Now, "add some additional spending money"); Console.WriteLine(giftCard.GetAccountHistory()); var savings = new InterestEarningAccount("savings account", 10000); savings.MakeDeposit(750, DateTime.Now, "save some money"); savings.MakeDeposit(1250, DateTime.Now, "Add more savings"); savings.MakeWithdrawal(250, DateTime.Now, "Needed to pay monthly bills"); savings.PerformMonthEndTransactions(); Console.WriteLine(savings.GetAccountHistory()); var lineOfCredit = new LineOfCreditAccount("line of credit", 0, 2000); // How much is too much to borrow? lineOfCredit.MakeWithdrawal(1000m, DateTime.Now, "Take out monthly advance"); lineOfCredit.MakeDeposit(50m, DateTime.Now, "Pay back small amount"); lineOfCredit.MakeWithdrawal(5000m, DateTime.Now, "Emergency funds for repairs"); lineOfCredit.MakeDeposit(150m, DateTime.Now, "Partial restoration on repairs"); lineOfCredit.PerformMonthEndTransactions(); Console.WriteLine(lineOfCredit.GetAccountHistory()); }
static void Main(string[] args) { var account = new BankAccount("Ayala", 1000); Console.WriteLine($"Acount {account.Number} was created for {account.Owner} with {account.Balance} initial balance!"); account.MakeWithDraw(500, DateTime.Now, "rent payment"); Console.WriteLine($"Saldo: {account.Balance}"); account.MakeDeposit(100, DateTime.Now, "Friend paid me back"); Console.WriteLine($"Saldo: {account.Balance}"); try { account.MakeWithDraw(750, DateTime.Now, "Attempt to overdraw"); } catch (InvalidOperationException e) { Console.WriteLine("Exception caught trying to overdraw"); Console.WriteLine(e.ToString()); } Console.WriteLine(account.GetAccountHistory()); Console.WriteLine("++++++++++++++++++++++++++++++++++++++++++++++++++++++"); var giftCard = new GiftCardAccount("gift card", 100, 50); giftCard.MakeWithDraw(20, DateTime.Now, "get expensive coffee"); giftCard.MakeWithDraw(50, DateTime.Now, "buy groceries"); Console.WriteLine("Perform Month:"); giftCard.PerformMonthEndTransactions(); // can make additional deposits: giftCard.MakeDeposit(27.50m, DateTime.Now, "add some additional spending money"); Console.WriteLine(giftCard.GetAccountHistory()); var savings = new InterestEarningAccount("savings account", 10000); savings.MakeDeposit(750, DateTime.Now, "save some money"); savings.MakeDeposit(1250, DateTime.Now, "Add more savings"); savings.MakeWithDraw(250, DateTime.Now, "Needed to pay monthly bills"); savings.PerformMonthEndTransactions(); Console.WriteLine(savings.GetAccountHistory()); var lineOfCredit = new LineOfCreditAccount("line of credit", 0); // How much is too much to borrow? lineOfCredit.MakeWithDraw(1000m, DateTime.Now, "Take out monthly advance"); lineOfCredit.MakeDeposit(50m, DateTime.Now, "Pay back small amount"); lineOfCredit.MakeWithDraw(5000m, DateTime.Now, "Emergency funds for repairs"); lineOfCredit.MakeDeposit(150m, DateTime.Now, "Partial restoration on repairs"); lineOfCredit.PerformMonthEndTransactions(); Console.WriteLine(lineOfCredit.GetAccountHistory()); }
static void Main(string[] args) { Console.WriteLine("Hello World!"); BankAccount acct = new BankAccount("David", 2000); Console.WriteLine($"Account {acct.Number} was created for {acct.Owner} with {acct.Balance} inital balance"); //test deposit and withdrawals acct.MakeWithdrawal(600, DateTime.Now, "Rent"); Console.WriteLine(acct.Balance); acct.MakeDeposit(500, DateTime.Now, "Refund of expensive purchase"); Console.WriteLine(acct.Balance); //force an error try { BankAccount test = new BankAccount("Invalid", -55); } catch (ArgumentOutOfRangeException e) { Console.WriteLine("Exception caught while making account"); Console.WriteLine(e.ToString()); } //test for negative balance try { acct.MakeWithdrawal(3000, DateTime.Now, "Attempt to overdraw"); } catch (InvalidOperationException e) { Console.WriteLine("Exception caught trying to overdraw"); Console.WriteLine(e.ToString()); } Console.WriteLine(acct.GetAccountHistory()); //------------------------------------------------------ //test of giftcards GiftCardAccount gc = new GiftCardAccount("Gift Card", 100, 50); gc.MakeWithdrawal(20, DateTime.Now, "Buy Coffee"); gc.MakeWithdrawal(50, DateTime.Now, "Buy Groceries"); gc.PerformMonthEndTransactions(); gc.MakeDeposit(27.50m, DateTime.Now, "Add additional Spending Money"); Console.WriteLine(gc.GetAccountHistory()); // test of Savings account InterestEarningAccount savings = new InterestEarningAccount("Savings Account", 10000); savings.MakeDeposit(750, DateTime.Now, "Save Some Money"); savings.MakeDeposit(1250, DateTime.Now, "Add More Savings"); savings.MakeWithdrawal(250, DateTime.Now, "Pay Monthly Bills"); savings.PerformMonthEndTransactions(); Console.WriteLine(savings.GetAccountHistory()); //---------------------------------------------------- // test line of credit var credit = new LineOfCreditAccount("Credit account", 0, 2000); credit.MakeWithdrawal(1000m, DateTime.Now, "Monthly Advance"); credit.MakeDeposit(50m, DateTime.Now, "Pay back small amount"); credit.MakeWithdrawal(5000m, DateTime.Now, "Emergency!"); credit.MakeDeposit(150m, DateTime.Now, "Partial Repayment of repairs"); credit.PerformMonthEndTransactions(); Console.WriteLine(credit.GetAccountHistory()); }