static void Main() { //Deposit Test var depositAccIndividual = new DepositAccount(CustomerType.Individual, 2000.78m, 0.5m); Console.WriteLine("Customer: {0} | Balance: ${1:F2} | Interest Amount (12 Months): ${2:F2}", depositAccIndividual.Customer, depositAccIndividual.Balance, depositAccIndividual.InterestAmount(12)); depositAccIndividual.Withdraw(1500); Console.WriteLine("Balance after Withdraw: ${0:F2}", depositAccIndividual.Balance); Console.WriteLine(); //Loan Test var loanAccCompany = new LoanAccount(CustomerType.Company, 3000000.1234m, 1.0m); Console.WriteLine("Customer: {0} | Balance: ${1:F2} | Interest Amount (1 Month): ${2:F2}", loanAccCompany.Customer, loanAccCompany.Balance, loanAccCompany.InterestAmount(1)); loanAccCompany.Deposit(1500000); Console.WriteLine("Balance after Deposit: ${0:F2}", loanAccCompany.Balance); Console.WriteLine("Interest Amount (13 Months): ${0:F2}", loanAccCompany.InterestAmount(13)); Console.WriteLine(); //Mortage Test var mortageAccCompany = new MortageAccount(CustomerType.Company, 17000000.98m, 1.5m); Console.WriteLine("Customer: {0} | Balance: ${1:F2} | Interest Amount (1 Month): ${2:F2}", mortageAccCompany.Customer, mortageAccCompany.Balance, mortageAccCompany.InterestAmount(1)); var mortageAccIndividual = new MortageAccount(CustomerType.Individual, 105000.13m, 1.0m); Console.WriteLine("Customer: {0} | Balance: ${1:F2} | Interest Amount (1 Month): ${2:F2}", mortageAccIndividual.Customer, mortageAccIndividual.Balance, mortageAccIndividual.InterestAmount(1)); }
public static void Main(string[] args) { 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("{0} {1,14:F2}", 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("{0} {1,14:F2}", account, account.InterestAmount(8)); } Console.WriteLine("\nInterest for next 20 mounts:"); foreach (var account in accounts) { Console.WriteLine("{0} {1,14:F2}", account, account.InterestAmount(20)); } }
static void Main(string[] args) { // Info for the Test // Declaring Companies and Individuals Company TBI = new Company("TBI", "Ivan"); Company puma = new Company("Puma", "Konstantin Filipov"); Company addidas = new Company("Addidas", "Martin Sonnerfeld"); Individual me = new Individual("Fancy", "Pants"); Individual somePerson = new Individual("Goldie", "Flint"); Individual otherPerson = new Individual("Richie", "Golden"); Individual thirdPerson = new Individual("Healthy", "Worths"); // Making Accounts of the bank to calculate their Rate // Some of them have the same interest rate to see if the overriden methods return // different rates for the different types of accounts Account[] bankAccounts = new Account[7]; bankAccounts[0] = new DepositAccount(TBI, 12000, 0.017); bankAccounts[1] = new LoanAccount(puma, 10000, 0.017); bankAccounts[2] = new MortageAccount(addidas, 11000, 0.017); bankAccounts[3] = new DepositAccount(me, 900, 0.037); bankAccounts[4] = new DepositAccount(somePerson, 1200, 0.047); bankAccounts[5] = new LoanAccount(otherPerson, 1000, 0.047); bankAccounts[6] = new MortageAccount(thirdPerson, 1100, 0.047); foreach (Account account in bankAccounts) { if (account.Customer is Individual) { Console.WriteLine("The customer is an individual. "); Console.WriteLine("His account is: Name: {0}, Balance: {1} leva" , account.Customer.Name, account.Balance.ToString()); Console.WriteLine("His interest Rate for two years: {0}", account.InterestAmount(24).ToString()); Console.WriteLine(); } else { Console.WriteLine("The customer is a company. "); Console.WriteLine("Its account is: Name: {0}, Balance: {1} leva" , account.Customer.Name, account.Balance.ToString()); Console.WriteLine("Its interest Rate for two years: {0}", account.InterestAmount(24).ToString()); Console.WriteLine(); } } }