Inheritance: Account, IDepositable
Example #1
0
        static void Main()
        {
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(new string('=', 42));

            // Create an instances of the new accounts
            DepositAccount  depositAcc  = new DepositAccount(CustomerType.Individual, "Gaius Julius Caesar", 3750, 5);
            LoanAccount     loanAccInd  = new LoanAccount(CustomerType.Individual, "King Leonidas", 5700, 4);
            LoanAccount     loanAccComp = new LoanAccount(CustomerType.Company, "Naglite Corp.", 67879, 3);
            MortgageAccount mortgageAcc = new MortgageAccount(CustomerType.Company, "Talasumi Ltd.", 3700, 4);

            // Testing of the Deposit Account, Custumer Type - Individual
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("Customer Name: {0}\nCustomer Type: {1}", depositAcc.Customer, depositAcc.CustomerType);
            Console.WriteLine("Deposit balance is: {0}", depositAcc.Balance);
            depositAcc.DepositMoney(3000);
            Console.WriteLine("After depositing of 3000 the balance is: {0}", depositAcc.Balance);

            Console.WriteLine("Deposit balance is: {0}", depositAcc.Balance);
            depositAcc.WithdrawMoney(1000);
            Console.WriteLine("After withdrawing 1000 the balance is: {0}", depositAcc.Balance);

            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(new string('=', 42));

            // Testing of the Loan Account, Custumer Type - Individual
            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.WriteLine("Customer Name: {0}\nCustomer Type: {1}", loanAccInd.Customer, loanAccInd.CustomerType);
            Console.WriteLine("Deposit balance is: {0}", loanAccInd.Balance);
            loanAccInd.DepositMoney(1000);
            Console.WriteLine("After deposition of 1000 balance is: {0}", loanAccInd.Balance);

            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(new string('=', 42));

            // Testing of the Loan Account, Custumer Type - Company
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Customer Name: {0}\nCustomer Type: {1}", loanAccComp.Customer, loanAccComp.CustomerType);
            Console.WriteLine("Deposit balance is: {0}", loanAccComp.Balance);
            loanAccComp.DepositMoney(7500);
            Console.WriteLine("After deposition of 7500 balance is: {0}", loanAccComp.Balance);

            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(new string('=', 42));

            // Testing the Interest Amount
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("Interest Ammount of the accounts for 18 months: \n{0}: {1} \n{2}: {3} \n{4}: {5}",
                              depositAcc.Customer, depositAcc.InterestAmount(18), loanAccInd.Customer, loanAccInd.InterestAmount(18),
                              loanAccComp.Customer, loanAccComp.InterestAmount(18), mortgageAcc.Customer, mortgageAcc.InterestAmount(18));

            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(new string('=', 42));
        }
Example #2
0
        static void Main()
        {
            DepositAccount deposit = new DepositAccount(Customer.Individual, 0, 0.5m);

            deposit.Deposit(2000);
            deposit.Deposit(3000);
            deposit.Withdraw(500);
            //Console.WriteLine(deposit.Balance);
            //Console.WriteLine(deposit.CalculateInterest(5));

            Account loan = new LoanAccount(Customer.Individual, 2000, 1m);

            //Console.WriteLine(loan.CalculateInterest(5));

            Account mortgage = new LoanAccount(Customer.Individual, 30000, 1m);

            Console.WriteLine(mortgage.CalculateInterest());
        }
Example #3
0
        public static void Main()
        {
            ICustomer gosho = new IndividualCustomer("Georgi Georgiev");
            ICustomer myCompany = new CompanyCustomer("My Company Ltd.");

            IAccount mortAccInd = new MortgageAccount(gosho, 924m, 2.4m);
            IAccount mortgageAccComp = new MortgageAccount(myCompany, 888m, 7.4m);

            IAccount loanAccInd = new LoanAccount(gosho, 2048m, 4.5m);
            IAccount loanAccComp = new LoanAccount(myCompany, 512m, 6.0m);

            IAccount depositAccIndBig = new DepositAccount(gosho, 888, 6.6m);
            IAccount depositAccIndSmall = new DepositAccount(gosho, 1111m, 7.9m);
            IAccount depositAccComp = new DepositAccount(myCompany, 50326m, 4.9m);

            List<IAccount> accounts = new List<IAccount>()
            {
                mortAccInd,
                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);
            }
        }
Example #4
0
        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);
            }
        }
Example #5
0
        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);
            }
        }
Example #6
0
        public static List <Account> Accounts()
        {
            var accounts       = new List <Account>();
            var customer       = new CustromerType();
            var depositAccount = new DepositAccount();
            var loanAccount    = new LoanAccount();

            Console.Write("Number of accounts to add: ");
            var numberOfAccounts = int.Parse(Console.ReadLine());

            for (int i = 1; i <= numberOfAccounts; i++)
            {
                var customerType = 0;
                var accountType  = 0;

                Console.WriteLine("[{0}] Account", i);
                do
                {
                    Console.WriteLine("Custromer types");
                    Console.WriteLine("1. Individual");
                    Console.WriteLine("2. Company");
                    Console.Write("Custromer: ");

                    customerType = int.Parse(Console.ReadLine());
                } while (customerType < 1 || customerType > 2);

                do
                {
                    Console.WriteLine("Account types");
                    Console.WriteLine("1. Deposit account");
                    Console.WriteLine("2. Loan account");
                    Console.WriteLine("3. Mortgage account");
                    Console.Write("Account: ");

                    accountType = int.Parse(Console.ReadLine());
                } while (accountType < 1 || accountType > 3);

                Console.Write("Balance: ");
                decimal balance = decimal.Parse(Console.ReadLine());
                Console.Write("Interest rate: ");
                decimal interestRate = decimal.Parse(Console.ReadLine());

                switch (customerType)
                {
                case 1:
                    customer = CustromerType.Individual;
                    break;

                case 2:
                    customer = CustromerType.Company;
                    break;
                }

                switch (accountType)
                {
                case 1:
                    accounts.Add(new DepositAccount(customer, balance, interestRate));
                    break;

                case 2:
                    accounts.Add(new LoanAccount(customer, balance, interestRate));
                    break;

                case 3:
                    accounts.Add(new MortgageAccount(customer, balance, interestRate));
                    break;

                default:
                    break;
                }
                Console.Clear();
            }

            return(accounts);
        }
        public static List<Account> Accounts()
        {
            var accounts = new List<Account>();
            var customer = new CustromerType();
            var depositAccount = new DepositAccount();
            var loanAccount = new LoanAccount();

            Console.Write("Number of accounts to add: ");
            var numberOfAccounts = int.Parse(Console.ReadLine());

            for (int i = 1; i <= numberOfAccounts; i++)
            {
                var customerType = 0;
                var accountType = 0;

                Console.WriteLine("[{0}] Account", i);
                do
                {
                    Console.WriteLine("Custromer types");
                    Console.WriteLine("1. Individual");
                    Console.WriteLine("2. Company");
                    Console.Write("Custromer: ");

                    customerType = int.Parse(Console.ReadLine());

                } while (customerType < 1 || customerType > 2);

                do
                {
                    Console.WriteLine("Account types");
                    Console.WriteLine("1. Deposit account");
                    Console.WriteLine("2. Loan account");
                    Console.WriteLine("3. Mortgage account");
                    Console.Write("Account: ");

                    accountType = int.Parse(Console.ReadLine());

                } while (accountType < 1 || accountType > 3);

                Console.Write("Balance: ");
                decimal balance = decimal.Parse(Console.ReadLine());
                Console.Write("Interest rate: ");
                decimal interestRate = decimal.Parse(Console.ReadLine());

                switch (customerType)
                {
                    case 1:
                        customer = CustromerType.Individual;
                        break;
                    case 2:
                        customer = CustromerType.Company;
                        break;
                }

                switch (accountType)
                {
                    case 1:
                        accounts.Add(new DepositAccount(customer, balance, interestRate));
                        break;
                    case 2:
                        accounts.Add(new LoanAccount(customer, balance, interestRate));
                        break;
                    case 3:
                        accounts.Add(new MortgageAccount(customer, balance, interestRate));
                        break;
                    default:
                        break;
                }
                Console.Clear();
            }

            return accounts;
        }