static void Main() { IndividualCustomer individualCustomer1 = new IndividualCustomer("Peter Johnson"); CompanyCustomer companyCustomer1 = new CompanyCustomer("Telerik"); Account[] accounts = { new DepositAccount(individualCustomer1, 2345M, 0.4M), new MortgageAccount(individualCustomer1, -230000M, 0.5M), new LoanAccount(companyCustomer1, -1000000M, 0.2M) }; foreach (Account account in accounts) { Console.WriteLine("The year interest is: {0:P}", account.CalculateInterest(12)); } Console.WriteLine(new string('=', 40)); Console.WriteLine("Balance: {0}", accounts[0].Balance); accounts[0].Deposit(200m); Console.WriteLine("Balance after deposit: {0}", accounts[0].Balance); (accounts[0] as DepositAccount).Withdraw(50m); Console.WriteLine("Balance after withdraw: {0}", accounts[0].Balance); Console.WriteLine("Balance: {0}", accounts[1].Balance); accounts[1].Deposit(1000m); Console.WriteLine("Balance after deposit: {0}", accounts[1].Balance); }
static void Main() { Customer IvanIvanov = new IndividualCustomer("Ivan Ivanov"); Customer PetarStoyanov = new IndividualCustomer("Petar Stoyanov"); Customer AnnaVasileva = new IndividualCustomer("Anna Vasileva"); Customer MariaAtanasova = new IndividualCustomer("Maria Atanasova "); Customer CocaCola = new CompanyCustomer("CocaCola"); Customer Microsoft = new CompanyCustomer("Microsoft"); Customer Apple = new CompanyCustomer("Apple"); Customer Google = new CompanyCustomer("Google"); DepositAccount depositIvanIvanov = new DepositAccount(IvanIvanov, 800m, 0.05m); DepositAccount depositCocaCola = new DepositAccount(CocaCola, 5000000m, 0.02m); LoanAccount loanAnnaVasilev = new LoanAccount(AnnaVasileva, -10000m, 0.12m); LoanAccount loanGoogle = new LoanAccount(Google, -1000000m, 0.08m); MortageAccount mortagePetarStoyanov = new MortageAccount(PetarStoyanov, -50000m, 0.07m); MortageAccount mortageMictosoft = new MortageAccount(Microsoft, -5000000m, 0.06m); IList <Account> accounts = new List <Account>(); accounts.Add(depositIvanIvanov); accounts.Add(depositCocaCola); accounts.Add(loanAnnaVasilev); accounts.Add(loanGoogle); accounts.Add(mortagePetarStoyanov); accounts.Add(mortageMictosoft); foreach (var account in accounts) { Console.WriteLine(account); } depositIvanIvanov.WithDraw(258.15m); Console.WriteLine("\nInterest for next 4 mounts:"); foreach (var account in accounts) { Console.WriteLine(account + " " + account.InterestAmount(4)); } depositIvanIvanov.Deposit(800m); loanAnnaVasilev.Deposit(600.12m); mortagePetarStoyanov.Deposit(1825.12m); Console.WriteLine("\nInterest for next 8 mounts:"); foreach (var account in accounts) { Console.WriteLine(account + " " + account.InterestAmount(8)); } Console.WriteLine("\nInterest for next 20 mounts:"); foreach (var account in accounts) { Console.WriteLine(account + " " + account.InterestAmount(20)); } }
static void Main() { CompanyCustomer company = new CompanyCustomer("X OOD"); IndividualCustomer individual = new IndividualCustomer("Ivan Petrov", 21); IndividualCustomer individual2 = new IndividualCustomer("Ivan Petrov", 16); Account[] accounts = { new Deposit(individual, 1500, 5, 12), new Loan(company, 50000, 5, 6), new Mortgage(individual2, 75000, 10, 24), }; foreach (var account in accounts) { Console.WriteLine(account); Console.WriteLine(); Console.WriteLine("{0}", new string('-', 40)); Console.WriteLine(); } }
public static void Main() { Customer misho = new IndividualCustomer("Misho Mishev", 7409128991); Customer actavis = new CompanyCustomer("Actavis", "BG9863535399"); var accounts = new List <Account>() { new DepositAccount(misho, 2999.99m, 3.5), new LoanAccount(misho, 2999.99m, 4.0), new MortgageAccount(misho, 2999.99m, 1.5), new DepositAccount(actavis, 3000000.50m, 4.5), new LoanAccount(actavis, 3000000.50m, 5.0), new MortgageAccount(actavis, 3000000.50m, 2.5) }; foreach (var account in accounts) { Console.WriteLine("--Customer:{0}--\nBalance: {1}\n {2} -> 3 months interest: {3}; 24 months interest: {4}", account.Customer.Name, account.Balance, account.GetType().Name, account.CalculateInterest(3), account.CalculateInterest(24)); } }
public static void Main() { ICustomer pesho = new IndividualCustomer("Petar Petrov"); ICustomer agroCompany = new CompanyCustomer("Agro Company Ltd."); IAccount mortgageAccInd = new MortgageAccount(pesho, 1024m, 5.3m); IAccount mortgageAccComp = new MortgageAccount(agroCompany, 1024m, 5.3m); IAccount loanAccInd = new LoanAccount(pesho, 1024m, 5.3m); IAccount loanAccComp = new LoanAccount(agroCompany, 1024m, 5.3m); IAccount depositAccIndBig = new DepositAccount(pesho, 1024m, 5.3m); IAccount depositAccIndSmall = new DepositAccount(pesho, 999m, 5.3m); IAccount depositAccComp = new DepositAccount(agroCompany, 11024m, 4.3m); List <IAccount> accounts = new List <IAccount>() { mortgageAccInd, mortgageAccComp, loanAccInd, loanAccComp, depositAccIndBig, depositAccIndSmall, depositAccComp }; foreach (var acc in accounts) { Console.WriteLine( "{5} {0,-15}: {1:N2}, {2:N2}, {3:N2}, {4:N2}", acc.GetType().Name, acc.CalculateRate(2), acc.CalculateRate(3), acc.CalculateRate(10), acc.CalculateRate(13), acc.Customer.GetType().Name); } }
static void Main(string[] args) { ICustomer pesho = new IndividualCustomer("Pesho Peshkov"); ICustomer apple = new CompanyCustomer("Qbalka"); IAccount mortgageAccInd = new MortgageAccount(pesho, 1024m, 5.3m); IAccount mortgageAccComp = new MortgageAccount(apple, 1024m, 5.3m); IAccount loanAccInd = new LoanAccount(pesho, 1024m, 5.3m); IAccount loanAccComp = new LoanAccount(apple, 1024m, 5.3m); IAccount depositAccIndBig = new DepositAccount(pesho, 1024m, 5.3m); IAccount depositAccIndSmall = new DepositAccount(pesho, 999m, 5.3m); IAccount depositAccComp = new DepositAccount(apple, 11024m, 4.3m); List<IAccount> accounts = new List<IAccount>() { mortgageAccInd, mortgageAccComp, loanAccInd, loanAccComp, depositAccIndBig, depositAccIndSmall, depositAccComp }; foreach (var acc in accounts) { Console.WriteLine( "{5} {0,-15}: {1:N2}, {2:N2}, {3:N2}, {4:N2}", acc.GetType().Name, acc.CalculateRate(2), acc.CalculateRate(3), acc.CalculateRate(10), acc.CalculateRate(13), acc.Customer.GetType().Name); } }