public static void Main() { Bank bank = new Bank(); bank.AddAccount(new LoanAccounts(new Individuals("Pesho Ivanov"), 1000, 20)); bank.AddAccount(new MortgageAccounts(new Companies("TeeeeeC LTD"), 100, 200)); bank.AddAccount(new DepositAccouts(new Individuals("Gosho Petrov"), 1000, 2)); foreach (var account in bank.Accounts) { Console.WriteLine("{0} for {1} with interest amount = {2} BGN", account.GetType().Name, account.Customer.Name, account.CalculateInterestAmount(12)); account.DepositMoney(50); account.DrawMoney(100); Console.WriteLine(account.Balance); } }
static void Main(string[] args) { //Add some customers var Antoan = new Individual("Antoan Elenkov"); var Georgi = new Individual("Georgi Ivanov"); var Mtel = new Company("Mtel"); var Telenor = new Company("Telenor"); //Add some Accounts var IndividualAcc1 = new DepositAcc(Antoan, new DateTime(14, 5, 24), 1100, 0.5); var IndividualAcc2 = new DepositAcc(Mtel, new DateTime(12, 5, 24), 500, 0.4); var companyAcc1 = new DepositAcc(Georgi, new DateTime(13, 5, 24), 5500.5m, .2); var companyAcc2 = new LoanAcc(Telenor, new DateTime(12, 5, 24), 500, .6); //Initialize bank - not needed var FIB = new Bank("FIB", new List<Account>()); FIB.AccountsCollection.Add(IndividualAcc1); FIB.AccountsCollection.Add(IndividualAcc2); FIB.AccountsCollection.Add(companyAcc1); FIB.AccountsCollection.Add(companyAcc2); //Individual Deposit account Console.WriteLine("\nIndividual Deposit account"); Console.WriteLine("Interest rate: {0}",IndividualAcc1.CalculateInterestRate(3)); Console.WriteLine("Balance before : {0}", IndividualAcc1.Balance); IndividualAcc1.Deposit(100000); Console.WriteLine("Balance after : {0}", IndividualAcc1.Balance); Console.WriteLine("Balance before : {0}", IndividualAcc1.Balance); IndividualAcc1.WithDraw(50000); Console.WriteLine("Balance after : {0}", IndividualAcc1.Balance); //Company Deposit account Console.WriteLine("\nCompany Deposit account"); Console.WriteLine("Interest rate: {0}", companyAcc1.CalculateInterestRate(3)); Console.WriteLine("Balance before : {0}", companyAcc1.Balance); companyAcc1.Deposit(6000); Console.WriteLine("Balance after : {0}", companyAcc1.Balance); Console.WriteLine("Balance before : {0}", companyAcc1.Balance); companyAcc1.WithDraw(100000); Console.WriteLine("Balance after : {0}", companyAcc1.Balance); //If you want, you can make some more tests :))) }
static void Main() { Bank bank = new Bank("FIB"); var peshoCompany = new Company("Hamali"); var pesho = new Individual("Pesho"); Console.WriteLine(peshoCompany is Company); //True Console.WriteLine(peshoCompany is Customer); //True Console.WriteLine(pesho is Individual); //True Console.WriteLine(pesho is Customer); //True Console.WriteLine(pesho is Company); //False Console.WriteLine(new string('-',50)); BankAccount[] accounts=new BankAccount[] { new DepositAccount(peshoCompany , 1300.80m,3.25m), new LoanAccount(pesho, 5000m, 10.8m), new MortgageAccount(new Company("Gosho company"),1000.80m, 4.7m), new DepositAccount(new Individual("Vasko","Mladost 1, bl.153", "+359888777333"),120.3m,4.14m) }; foreach (var acc in accounts) { bank.AddAccount(acc); } Console.WriteLine(bank); Console.WriteLine(new string('-', 50)); try { foreach (var acc in accounts) { acc.Deposit(200); Console.WriteLine(acc); Console.WriteLine(); } } catch (Exception e) { Console.WriteLine(e.Message); } try { foreach (var acc in accounts) { acc.Deposit(-50); } } catch (Exception e) { Console.WriteLine(e.Message); } Console.WriteLine(new string('-', 50)); foreach (var acc in accounts) { Console.WriteLine(acc.CalculateInterest(6)); } Console.WriteLine(new string('-', 50)); var depositAcount = accounts[0] as DepositAccount; depositAcount.Withdraw(800); Console.WriteLine(depositAcount); Console.WriteLine(new string('-', 50)); try { depositAcount.Withdraw(1000); Console.WriteLine(depositAcount); } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.WriteLine(new string('-', 50)); }