Esempio n. 1
0
        static void Main()
        {
            ICustomer[] clients =
            {
                new IndividualCustomer("Kiril"),
                new IndividualCustomer("Nakov"),
                new CompanyCustomer("SoftUni"),
            };

            DepositAccount  kirilDepositAccount  = new DepositAccount(clients[0], 888.354m, 55);
            MortgageAccount nakovMortgageAccount = new MortgageAccount(clients[1], 3415.77m, 12);
            LoanAccount     softUniLoanAccount   = new LoanAccount(clients[2], 56756.789m, 3);

            kirilDepositAccount.Withdraw(123.77m);
            nakovMortgageAccount.Deposit(124.55m);
            softUniLoanAccount.Deposit(1779.33m);

            // Try false input
            try
            {
                kirilDepositAccount.Withdraw(1000m);
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.WriteLine(kirilDepositAccount);
            Console.WriteLine(nakovMortgageAccount);
            Console.WriteLine(softUniLoanAccount + $"\nInterest rate: {softUniLoanAccount.CalculateInterest(3)}");
        }
Esempio n. 2
0
        public static void Main()
        {
            ICustomer[] clients =
            {
                new IndividualCustomer("Pesho"),
                new IndividualCustomer("Gosho"),
                new CompanyCustomer("Soft Uni LTD"),
                new CompanyCustomer("Manchester United FC"),
            };

            var depositAcc = new DepositAccount(clients[0], 8955.33m, 0.005);
            var loanAcc = new LoanAccount(clients[1], 500m, 0.002);
            var mortgageAcc = new MortgageAccount(clients[2], 5m, 0.009);
            var depositAcc2 = new DepositAccount(clients[3], 159, 0.08);

            depositAcc.Withdraw(6000m);
            depositAcc2.Withdraw(54.22m);
            mortgageAcc.Deposit(15m);
            loanAcc.Deposit(5559.66m);

            try
            {
                depositAcc.Withdraw(500000000m);
            }
            catch (ArgumentException ex)
            {
                Console.Error.WriteLine(ex.Message);
            }

            Console.WriteLine(depositAcc2);
            Console.WriteLine(mortgageAcc);

            Console.WriteLine(loanAcc + $" Interest rate: {loanAcc.CalculateIntereset(12):C}");
        }
Esempio n. 3
0
        // Write a program to model the bank system by classes and interfaces.
        // Identify the classes, interfaces, base classes and abstract actions
        // and implement the calculation of the interest functionality through overridden methods.
        private static void Main()
        {
            Client client1 = new ClientIndividual("Neo");
            Client client2 = new ClientCompany("Office 1");
            Client client3 = new ClientIndividual("Nakov");

            Account acc1 = new DepositAccount(client1, 5, "BG13TLRK01");
            Account acc2 = new LoanAccount(client2, 4.5m, "BG13TLRK02");
            Account acc3 = new MortgageAccount(client3, 8.8m, "BG13TLRK03");

            acc1.DepositMoney(1000);
            ((DepositAccount)acc1).WithdrawMoney(500);
            acc2.DepositMoney(10000);

            Bank bank = new Bank("New Bank");

            bank.AddAccount(acc1);
            bank.AddAccount(acc2);
            bank.AddAccount(acc3);

            Console.WriteLine(bank.Accounts);

            Console.WriteLine();
            Console.WriteLine("IBAN: {0} ({1}), Interest: {2:F2}", acc1.IBAN, acc1.Owner.Name, acc1.CalculateInterest(5));
            Console.WriteLine("IBAN: {0} ({1}), Interest: {2:F2}", acc2.IBAN, acc2.Owner.Name, acc2.CalculateInterest(6));
            Console.WriteLine("IBAN: {0} ({1}), Interest: {2:F2}", acc3.IBAN, acc3.Owner.Name, acc3.CalculateInterest(18));

            Console.WriteLine("\nRemoving account 1");
            bank.RemoveAccount(acc1);
            Console.WriteLine(bank.Accounts);
        }
Esempio n. 4
0
        private static void CreateAccount(Customer customer)
        {
            string accountType;
            double startingBalance;
            string accountNumber = "ABC0000";

            do
            {
                Console.Write("Enter Account Type(Mortgage/Loan/Deposit): ");
                accountType = Console.ReadLine();
            }while (!String.Equals(accountType, "Mortgage") && !String.Equals(accountType, "Loan") && !String.Equals(accountType, "Deposit"));

            Console.Write("Enter Starting Balance: ");
            startingBalance = Convert.ToDouble(Console.ReadLine());
            accountNumber   = accountNumber + _rand.Next(5, 10);
            if (String.Equals(accountType, "Mortgage"))
            {
                var mortgageAccount = new MortgageAccount(customer, startingBalance, accountNumber);
                _accounts.Add(mortgageAccount);
            }
            else if (String.Equals(accountType, "Loan"))
            {
                var loanAccount = new LoanAccount(customer, startingBalance, accountNumber);
                _accounts.Add(loanAccount);
            }
            else
            {
                var depoAccount = new DepositAccount(customer, startingBalance, accountNumber);
                _accounts.Add(depoAccount);
            }
        }
Esempio n. 5
0
        public static void Main()
        {
            ICustomer[] clients =
            {
                new IndividualCustomer("Pesho"),
                new IndividualCustomer("Gosho"),
                new CompanyCustomer("Soft Uni LTD"),
                new CompanyCustomer("Soft Uni Student Organisation"),
            };

            var depositAcc  = new DepositAccount(clients[0], 8955.33m, 0.005);
            var loanAcc     = new LoanAccount(clients[1], 1200m, 0.002);
            var mortgageAcc = new MortgageAccount(clients[2], 7005m, 0.009);
            var depositAcc2 = new DepositAccount(clients[3], 159, 0.08);

            depositAcc.Withdraw(6000m);
            depositAcc2.Withdraw(54.22m);
            mortgageAcc.Deposit(15m);
            loanAcc.Deposit(5559.66m);

            try
            {
                depositAcc.Withdraw(500000000m);
            }
            catch (ArgumentException ex)
            {
                Console.Error.WriteLine(ex.Message);
            }

            Console.WriteLine(depositAcc2);
            Console.WriteLine(mortgageAcc);

            Console.WriteLine(loanAcc + $" Interest rate: {loanAcc.CalculateIntereset(12):C}");
        }
Esempio n. 6
0
        static void Main()
        {
            ICustomer[] clients =
            {
                new IndividualCustomer("Kiril"),
                new IndividualCustomer("Nakov"),
                new CompanyCustomer("SoftUni"),
            };

            DepositAccount kirilDepositAccount = new DepositAccount(clients[0],888.354m,55);
            MortgageAccount nakovMortgageAccount = new MortgageAccount(clients[1],3415.77m,12);
            LoanAccount softUniLoanAccount = new LoanAccount(clients[2],56756.789m,3);

            kirilDepositAccount.Withdraw(123.77m);
            nakovMortgageAccount.Deposit(124.55m);
            softUniLoanAccount.Deposit(1779.33m);

            // Try false input
            try
            {
                kirilDepositAccount.Withdraw(1000m);
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.WriteLine(kirilDepositAccount);
            Console.WriteLine(nakovMortgageAccount);
            Console.WriteLine(softUniLoanAccount + $"\nInterest rate: {softUniLoanAccount.CalculateInterest(3)}");

        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            Individual kiro = new Individual("Kiro");
            Individual ivan = new Individual("Ivan");
            Company    sap  = new Company("SAP");

            DepositAccount  kiroAccount = new DepositAccount(kiro, 1112, 0.2m);
            LoanAccount     ivanAccount = new LoanAccount(ivan, 2222, 0.29m);
            MortgageAccount sapAccount  = new MortgageAccount(sap, 3333, 0.23m);

            List <Account> accounts = new List <Account>()
            {
                kiroAccount,
                ivanAccount,
                sapAccount
            };

            foreach (var account in accounts)
            {
                Console.WriteLine(account);
            }

            Console.WriteLine(kiroAccount.CalculateInterestrate(4));
            Console.WriteLine(sapAccount.CalculateInterestrate(55));
            sapAccount.Deposit(4141);
            kiroAccount.Withdraw(333);

            foreach (var account in accounts)
            {
                Console.WriteLine(account);
            }
        }
Esempio n. 8
0
    static void Main()
    {
        Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

        DepositAccount depAccountInd = new DepositAccount(new Individual("Boyko Draganov", "9090909090"), 230m, 0.003m);
        DepositAccount depAccountComp = new DepositAccount(new Company("Barista", "999999999"), 13000m, 0.006m);

        MortgageAccount mortAccountInd = new MortgageAccount(new Individual("Georgi Dimitrov", "9090909190"), 2300m, 0.005m);
        MortgageAccount mortAccountComp = new MortgageAccount(new Company("Sky", "999999999"), 35000m, 0.008m);

        LoanAccount loanAccountInd = new LoanAccount(new Individual("Hani Kovachev", "9090909190"), 2300m, 0.005m);
        LoanAccount loanAccountComp = new LoanAccount(new Company("Scraper BG", "999999999"), 5000m, 0.002m);

        List<Account> accounts = new List<Account>(){depAccountInd, depAccountComp, mortAccountInd, mortAccountComp,
        loanAccountInd, loanAccountComp};

        foreach (var acc in accounts)
        {
            Console.WriteLine("I am {0}, I am owned by {1}, my current balance is \n{2} and the interest rate for {3} months is: {4:F2}", acc.GetType(),
                acc.Customer.GetType(), acc.Balance, 3, acc.CalculateInterest(3));
            Console.WriteLine(new string('-', 50));
        }
        depAccountInd.DepositMoney(1000);
        depAccountInd.WithdrawMoney(130);

        Console.WriteLine("Deposit Account owned by Individual:\nMy current balance is:{0}, and my interest for 2 months is: {1:F2}",
        depAccountInd.Balance, depAccountInd.CalculateInterest(2));
    }
Esempio n. 9
0
        public static void Main()
        {
            ICustomer[] clients =
            {
                new IndividualCustomer("Dimitar Dimitrov"),
                new IndividualCustomer("Petar Ivanov"),
                new CompanyCustomer("Glavbulgarstroy OOD"),
                new CompanyCustomer("Monbat AD"),
            };

            var depositAccount = new DepositAccount(clients[0], 18000m, 0.004);
            var loanAccount = new LoanAccount(clients[1], 500m, 0.015);
            var mortgageAccount = new MortgageAccount(clients[0], 5000m, 0.009);
            var depositAccount2 = new DepositAccount(clients[2], 100000m, 0.010);
            var depositAccount3 = new DepositAccount(clients[3], 1200, 0.08);

            depositAccount.Withdraw(1000m);
            depositAccount2.Withdraw(500m);
            mortgageAccount.Deposit(15m);
            loanAccount.Deposit(100m);

            try
            {
                depositAccount.Withdraw(100000m);
            }
            catch (ArgumentException ex)
            {
                Console.Error.WriteLine(ex.Message);
            }

            Console.WriteLine(depositAccount2);
            Console.WriteLine(mortgageAccount);

            Console.WriteLine(loanAccount + string.Format(" Interest : {0:C}", loanAccount.CalculateInterest(12)));
        }
Esempio n. 10
0
        static void Main()
        {
            Customers kris = new Individuals("Kris", "65654756765", "Sofia", new DateTime(1990, 10, 25));

            Customers krisOOD = new Companies("Kris OOD", "65654656765", "Plovdiv", 325343);

            Console.WriteLine(krisOOD is Individuals);
            Console.WriteLine(kris is Individuals);

            Bank mortgageAccTest = new MortgageAccount(200.2m, 0.6m, kris);
            Bank mortgageAccTest1 = new MortgageAccount(200.2m, 0.6m, krisOOD);

            Console.WriteLine(mortgageAccTest.CalculateInterest(15));
            Console.WriteLine(mortgageAccTest1.CalculateInterest(15));

            Bank loanAccTest = new LoanAccount(200.2m, 0.6m, kris);
            Bank loanAccTest1 = new LoanAccount(200.2m, 0.6m, krisOOD);

            Console.WriteLine(loanAccTest.CalculateInterest(11));
            Console.WriteLine(loanAccTest1.CalculateInterest(11));

            Bank depositAccTest = new DepositAccount(3200.2m, 0.6m, kris);
            Bank depositAccTest1 = new DepositAccount(1200.2m, 0.6m, krisOOD);

            Console.WriteLine(depositAccTest.CalculateInterest(11));
            Console.WriteLine(depositAccTest1.CalculateInterest(11));

            depositAccTest.Deposit(200);
            Console.WriteLine(depositAccTest.Balance);
            var depositAcc = depositAccTest as DepositAccount;
            depositAcc.Draw(300);
            Console.WriteLine(depositAcc.Balance);
        }
Esempio n. 11
0
    static void Main()
    {
        Bank bank = new Bank();

        DepositAccount depAccC = new DepositAccount(new Company(), 300M, 0.4M);
        DepositAccount depAccI = new DepositAccount(new Individual(), 1000M, 0.4M);

        LoanAccount loanAccC = new LoanAccount(new Company(), 1000M, 0.4M);
        LoanAccount loanAccI = new LoanAccount(new Individual(), 1000M, 0.4M);

        MortgageAccount mortAccC = new MortgageAccount(new Company(), 1000M, 0.4M);
        MortgageAccount mortAccI = new MortgageAccount(new Individual(), 1000M, 0.4M);

        bank.AddAccount(depAccC);
        bank.AddAccount(depAccI);
        bank.AddAccount(loanAccC);
        bank.AddAccount(loanAccI);
        bank.AddAccount(mortAccC);
        bank.AddAccount(mortAccI);

        foreach (var acc in bank.Accounts)
        {
            Console.WriteLine(acc.CalculateInterestAmount(12));
        }
    }
        private static void Main(string[] args)
        {
            var mortgage = new MortgageAccount(12000m, 0.05m, CustomerType.Individual);
            var deposit = new DepositAccount(1340m, 0.02m, CustomerType.Individual);
            var loan = new LoanAccount(10000m, 0.1m, CustomerType.Individual);
            var mortgage2 = new MortgageAccount(12000m, 0.05m, CustomerType.Company);
            var deposit2 = new DepositAccount(1340m, 0.02m, CustomerType.Company);
            var loan2 = new LoanAccount(10000m, 0.1m, CustomerType.Company);

            deposit.Withdraw(111);
            deposit2.Withdraw(222);

            var accounts = new List<Account>
            {
                mortgage,
                deposit,
                loan,
                mortgage2,
                deposit2,
                loan2
            };

            foreach (var account in accounts)
            {
                Console.WriteLine("Account type: {0}",account.GetType().Name);
                Console.WriteLine("Account balance after 12 months with {0:P} interest: {1:C}", account.InterestRate,
                    account.CalculateInterest(12));
                account.Deposit(100);
                Console.WriteLine("Account balance: {0:C}\n", account.Balance);
            }
        }
        static void Main()
        {
            Bank bank = new Bank("WeStealYourMoney");

            Customers firstOwner = new Customers("Ivan Georgiev");
            DepositAccount deposit = new DepositAccount(firstOwner, 16034, 4.5m);
            bank.AddAccount(deposit);

            Customers secondOwner = new Customers("Iliana Ignatova");
            MortgageAccount mortage = new MortgageAccount(secondOwner, 600, 4.5m);
            bank.AddAccount(mortage);

            Customers ThirdOwner = new Customers("Milen Minev");
            LoanAccount loan = new LoanAccount(ThirdOwner, 800, 6.5m);
            bank.AddAccount(loan);

            Console.WriteLine(bank);

            for (int i = 0; i < bank.accounts.Count; i++)
            {
                Console.WriteLine();
                Console.WriteLine("Account {0}: ", i + 1);
                Console.WriteLine(bank.accounts[i]);
            }
        }
Esempio n. 14
0
    static void Main()
    {
        Bank bank = new Bank();

        DepositAccount depAccC = new DepositAccount(new Company(), 300M, 0.4M);
        DepositAccount depAccI = new DepositAccount(new Individual(), 1000M, 0.4M);

        LoanAccount loanAccC = new LoanAccount(new Company(), 1000M, 0.4M);
        LoanAccount loanAccI = new LoanAccount(new Individual(), 1000M, 0.4M);

        MortgageAccount mortAccC = new MortgageAccount(new Company(), 1000M, 0.4M);
        MortgageAccount mortAccI = new MortgageAccount(new Individual(), 1000M, 0.4M);

        bank.AddAccount(depAccC);
        bank.AddAccount(depAccI);
        bank.AddAccount(loanAccC);
        bank.AddAccount(loanAccI);
        bank.AddAccount(mortAccC);
        bank.AddAccount(mortAccI);

        foreach (var acc in bank.Accounts)
        {
            Console.WriteLine(acc.CalculateInterestAmount(12));
        }
    }
Esempio n. 15
0
        public static void Main()
        {
            Bank bank = new Bank();

            Customer pesho  = new Customer("Pesho", CustomerType.Individual);
            Customer milko  = new Customer("Milko", CustomerType.Individual);
            Customer jichka = new Customer("jichka", CustomerType.Individual);

            Customer dell  = new Customer("Dell", CustomerType.Company);
            Customer hp    = new Customer("HP", CustomerType.Company);
            Customer apple = new Customer("Apple", CustomerType.Company);

            DepositAccount  peshoAccount  = new DepositAccount(pesho, 4300, 2.2m);
            LoanAccount     milkoAccount  = new LoanAccount(milko, 9999, 3.7m);
            MortgageAccount jichkaAccount = new MortgageAccount(jichka, 559, 1.2m);

            Account dellAccount  = new DepositAccount(dell, 17631782.4234m, 7.1m);
            Account hpAccount    = new LoanAccount(hp, 111111.1114m, 4.4m);
            Account appleAccount = new MortgageAccount(apple, 1888631782.4934234m, 11.1m);

            peshoAccount.Deposit(400.50m);
            peshoAccount.Withdraw(200);

            bank.AddAccount(peshoAccount);
            bank.AddAccount(milkoAccount);
            bank.AddAccount(jichkaAccount);
            bank.AddAccount(dellAccount);
            bank.AddAccount(hpAccount);
            bank.AddAccount(appleAccount);

            foreach (IAccount account in bank.Accounts)
            {
                Console.WriteLine($"{account} -- with interest for 23 months -> {account.CalculateInterest(23):F1}\n");
            }
        }
Esempio n. 16
0
        static void Main()
        {
            DepositAccount depositAccount = new DepositAccount(new Customer("Pesho", "individual"), 1200m, 10m);
            DepositAccount companyDepositAccount = new DepositAccount(new Customer("Goshos", "company"), 160000m, 8m);
            LoanAccount loanAccount = new LoanAccount(new Customer("Gosho", "individual"), 8000m, 12m);
            MortgageAccount morgageAccount = new MortgageAccount(new Customer("Peshovi", "company"), 12000m, 16m);

            Console.WriteLine("Deposit balanse: " + depositAccount.Balance);
            depositAccount.Deposit(1000);
            Console.WriteLine("After deposit 1000: " + depositAccount.Balance);
            depositAccount.Withdraw(1200);
            Console.WriteLine("After withdraw 1200: " + depositAccount.Balance);
            Console.WriteLine();

            Console.WriteLine("Loan balanse: " + loanAccount.Balance);
            loanAccount.Deposit(1000);
            Console.WriteLine("After deposit 1000: " + loanAccount.Balance);
            Console.WriteLine();

            Console.WriteLine("Morgage balanse: " + morgageAccount.Balance);
            morgageAccount.Deposit(1000);
            Console.WriteLine("After deposit 1000: " + morgageAccount.Balance);
            Console.WriteLine();

            Console.WriteLine("Diderent interest calculations: ");
            Console.WriteLine(depositAccount.CalculateInterest(5));
            Console.WriteLine(depositAccount.CalculateInterest(5));
            Console.WriteLine(loanAccount.CalculateInterest(3));
            Console.WriteLine(loanAccount.CalculateInterest(4));
            Console.WriteLine(morgageAccount.CalculateInterest(6));
            Console.WriteLine(morgageAccount.CalculateInterest(7));
            Console.WriteLine(companyDepositAccount.CalculateInterest(12));
            Console.WriteLine(companyDepositAccount.CalculateInterest(13));
        }
Esempio n. 17
0
        public static Account GetAccount(IAccountConfigOptions config)
        {
            Account accnt;

            switch (config.AccountType)
            {
            case AccountType.CHECKING:
                accnt = new CheckingAccount(config as CheckingAccountConfigOptions);
                break;

            case AccountType.SAVINGS:
                accnt = new SavingsAccount(config as SavingsAccountConfigOptions);
                break;

            case AccountType.CREDIT:
                accnt = new CreditAccount(config as CreditAccountConfigOptions);
                break;

            case AccountType.MORTGAGE:
                accnt = new MortgageAccount(config as MortgageAccountConfigOptions);
                break;

            default:
                throw new InvalidAccountTypeException("Unsupported Account Type");
            }
            return(accnt);
        }
        static void Main()
        {
            Console.WriteLine("DEPOSIT ACCOUNT");
            DepositAccount depositAccount = new DepositAccount(Customer.Companies, 5000.50m, 4.5m);
            Console.WriteLine(depositAccount.InterestRateForAPeriodCalculation(5));
            Console.WriteLine(depositAccount.Balance);
            depositAccount.Deposit(1000m);
            Console.WriteLine(depositAccount.Balance);
            Console.WriteLine(depositAccount.InterestRateForAPeriodCalculation(5));
            depositAccount.Widthraw(5500m);
            Console.WriteLine(depositAccount.Balance);
            Console.WriteLine(depositAccount.InterestRateForAPeriodCalculation(5));
            Console.WriteLine();

            Console.WriteLine("LOAN ACCOUNT");
            LoanAccount loanAccount = new LoanAccount(Customer.Individual, 5000, 10);
            Console.WriteLine(loanAccount.InterestRateForAPeriodCalculation(3));

            loanAccount.Customer = Customer.Companies;
            Console.WriteLine(loanAccount.InterestRateForAPeriodCalculation(3));
            Console.WriteLine();

            Console.WriteLine("MORTGAGE ACCOUNT");
            MortgageAccount mortgageAccount = new MortgageAccount(Customer.Companies, 4000m, 5.45m);
            Console.WriteLine(mortgageAccount.InterestRateForAPeriodCalculation(6));
        }
Esempio n. 19
0
        static void Main()
        {
            IAccount       depositIndividualAccount = new DepositAccount(Customer.Individual, 120.00m, 21.00m);
            DepositAccount depositCompany           = new DepositAccount(Customer.Company, 240.00m, 25.00m);
            IAccount       loanIndividial           = new LoanAccount(Customer.Individual, 20.00m, 15.00m);
            IAccount       loanCompany        = new LoanAccount(Customer.Company, 200.00m, 17.00m);
            IAccount       mortgageIndividial = new MortgageAccount(Customer.Individual, 2000.00m, 5.00m);
            IAccount       mortgageCompany    = new MortgageAccount(Customer.Company, 5000.00m, 7.00m);

            Console.WriteLine("Deposit individial account CalculateInterestAmountForPeriod for 5 month is ${0}",
                              depositIndividualAccount.CalculateInterestAmountForPeriod(5));
            Console.WriteLine("Deposit individial account Balance before deposit is ${0}", depositIndividualAccount.Balance);
            depositIndividualAccount.Deposit(50);
            Console.WriteLine("Deposit individial account Balance after deposit is ${0}", depositIndividualAccount.Balance);
            Console.WriteLine("Deposit company account CalculateInterestAmountForPeriod for 2 month is ${0}",
                              depositCompany.CalculateInterestAmountForPeriod(2));
            Console.WriteLine("Deposit company account Balance before draw money is ${0}", depositCompany.Balance);
            depositCompany.DrawMoney(2000);
            Console.WriteLine("Deposit company account Balance after draw money is ${0}", depositCompany.Balance);
            Console.WriteLine("Loan individial account CalculateInterestAmountForPeriod for 2 month is ${0}",
                              loanIndividial.CalculateInterestAmountForPeriod(2));
            Console.WriteLine("Loan company account CalculateInterestAmountForPeriod for 1 month is ${0}",
                              loanCompany.CalculateInterestAmountForPeriod(1));
            Console.WriteLine("Mortgage individial account CalculateInterestAmountForPeriod for 6 month is ${0}",
                              mortgageIndividial.CalculateInterestAmountForPeriod(6));
            Console.WriteLine("Mortgage company account CalculateInterestAmountForPeriod for 7 month is ${0}",
                              mortgageCompany.CalculateInterestAmountForPeriod(7));
        }
Esempio n. 20
0
    static void Main()
    {
        Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

        DepositAccount depAccountInd  = new DepositAccount(new Individual("Boyko Draganov", "9090909090"), 230m, 0.003m);
        DepositAccount depAccountComp = new DepositAccount(new Company("Barista", "999999999"), 13000m, 0.006m);

        MortgageAccount mortAccountInd  = new MortgageAccount(new Individual("Georgi Dimitrov", "9090909190"), 2300m, 0.005m);
        MortgageAccount mortAccountComp = new MortgageAccount(new Company("Sky", "999999999"), 35000m, 0.008m);

        LoanAccount loanAccountInd  = new LoanAccount(new Individual("Hani Kovachev", "9090909190"), 2300m, 0.005m);
        LoanAccount loanAccountComp = new LoanAccount(new Company("Scraper BG", "999999999"), 5000m, 0.002m);

        List <Account> accounts = new List <Account>()
        {
            depAccountInd, depAccountComp, mortAccountInd, mortAccountComp,
            loanAccountInd, loanAccountComp
        };


        foreach (var acc in accounts)
        {
            Console.WriteLine("I am {0}, I am owned by {1}, my current balance is \n{2} and the interest rate for {3} months is: {4:F2}", acc.GetType(),
                              acc.Customer.GetType(), acc.Balance, 3, acc.CalculateInterest(3));
            Console.WriteLine(new string('-', 50));
        }
        depAccountInd.DepositMoney(1000);
        depAccountInd.WithdrawMoney(130);

        Console.WriteLine("Deposit Account owned by Individual:\nMy current balance is:{0}, and my interest for 2 months is: {1:F2}",
                          depAccountInd.Balance, depAccountInd.CalculateInterest(2));
    }
        public static void Main()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            DepositAccount dep = new DepositAccount(cust: Customer.Company, balance: 200, interestRate: 20);

            Console.WriteLine("Deposit account's Interest Amount: {0}", dep.GetInterestAmount(months: 6));

            // when balance is more than 1000
            dep.Deposit(900m);
            Console.WriteLine("Deposit account's Interest Amount: {0}\n", dep.GetInterestAmount(months: 6));

            // individual
            LoanAccount loanIndividual = new LoanAccount(cust: Customer.Individual, balance: 100, interestRate: 15);

            Console.WriteLine("Loan individual account's Interest Amount: {0}", loanIndividual.GetInterestAmount(months: 3));
            Console.WriteLine("Loan individual account's Interest Amount: {0}\n", loanIndividual.GetInterestAmount(months: 5));

            // company
            LoanAccount loanCompany = new LoanAccount(cust: Customer.Company, balance: 100, interestRate: 15);

            Console.WriteLine("Loan company account's Interest Amount: {0}", loanCompany.GetInterestAmount(months: 2));
            Console.WriteLine("Loan company account's Interest Amount: {0}\n", loanCompany.GetInterestAmount(months: 5));

            // individual
            MortgageAccount mortIndividual = new MortgageAccount(cust: Customer.Individual, balance: 350, interestRate: 5);

            Console.WriteLine("Mortgage individual account's Interest Amount: {0}", mortIndividual.GetInterestAmount(months: 7));
            Console.WriteLine("Mortgage individual account's Interest Amount: {0}\n", mortIndividual.GetInterestAmount(months: 8));

            // company
            MortgageAccount mortCompany = new MortgageAccount(cust: Customer.Company, balance: 20000, interestRate: 10);

            Console.WriteLine("Mortgage company account's Interest Amount: {0}", mortCompany.GetInterestAmount(months: 10));
            Console.WriteLine("Mortgage company account's Interest Amount: {0}\n", mortCompany.GetInterestAmount(months: 24));
        }
        static void Main()
        {
            // Making instances of all types of accounts with the two types of customers
            DepositAccount first = new DepositAccount(new IndividualCustomer("Jimmy Hendrix"), 1500, 5);
            DepositAccount second = new DepositAccount(new CompanyCustomer("Jimmy Hendrix"), 500, 5);
            LoanAccount third = new LoanAccount(new IndividualCustomer("Jimmy Hendrix"), 4000, 7);
            LoanAccount fourth = new LoanAccount(new CompanyCustomer("Jimmy Hendrix"), 50000, 3);
            MortgageAccount fifth = new MortgageAccount(new IndividualCustomer("Jimmy Hendrix"), 34000, 4);
            MortgageAccount sixth = new MortgageAccount(new CompanyCustomer("Jimmy Hendrix"), 19000, 9);
            // Testing the DepositMoney, WithDrawMoney and CalculateInterest methods for all account types
            Console.WriteLine("INDIVIDUAL DEPOSIT ACCOUNT:");
            Console.WriteLine("Balance: {0}", first.Balance);
            first.DepositMoney(10);
            Console.WriteLine("Balance after deposit: {0}", first.Balance);
            first.WithDrawMoney(150);
            Console.WriteLine("Balance after withdraw: {0}", first.Balance);
            Console.WriteLine("Calculate interest: {0}", first.CalculateInterest(5));
            Console.WriteLine();
            Console.WriteLine("CUSTOMER DEPOSIT ACCOUNT: ");
            Console.WriteLine("Balance: {0}", second.Balance);
            second.DepositMoney(2000);
            Console.WriteLine("Balance after deposit: {0}", second.Balance);
            second.WithDrawMoney(1800);
            Console.WriteLine("Balance after withdraw: {0}", second.Balance);
            Console.WriteLine("Calculate interest: {0}", second.CalculateInterest(9));
            Console.WriteLine();
            Console.WriteLine("INDIVIDUAL LOAN ACCOUNT:");
            Console.WriteLine("Balance: {0}", third.Balance);
            third.DepositMoney(60);
            Console.WriteLine("Balance after deposit: {0}", third.Balance);
            Console.WriteLine("Calculate interest: {0}", third.CalculateInterest(7));
            Console.WriteLine();
            Console.WriteLine("CUSTOMER LOAN ACCOUNT:");
            Console.WriteLine("Balance: {0}", fourth.Balance);
            fourth.DepositMoney(60);
            Console.WriteLine("Balance after deposit: {0}", fourth.Balance);
            Console.WriteLine("Calculate interest: {0}", fourth.CalculateInterest(9));
            Console.WriteLine();
            Console.WriteLine("INDIVIDUAL MORTGAGE ACCOUNT:");
            Console.WriteLine("Balance: {0}", fifth.Balance);
            fifth.DepositMoney(100);
            Console.WriteLine("Balance after deposit: {0}", fifth.Balance);
            Console.WriteLine("Calculate interest: {0}", fifth.CalculateInterest(6));
            Console.WriteLine();
            Console.WriteLine("CUSTOMER MORTGAGE ACCOUNT:");
            Console.WriteLine("Balance: {0}", sixth.Balance);
            sixth.DepositMoney(100);
            Console.WriteLine("Balance after deposit: {0}", sixth.Balance);
            Console.WriteLine("Calculate interest: {0}", sixth.CalculateInterest(11));

            // Testing the Bank class and the AddAccount method
            Bank newBank = new Bank(LoadList());
            Console.WriteLine();
            newBank.AddAccount(new DepositAccount(new IndividualCustomer("Joe Rogan"), 780, 3));
            Console.WriteLine("Type of customer: " + newBank.Accounts[6].Customer.GetType().Name);
            Console.WriteLine("Name: " + newBank.Accounts[6].Customer.Name);
            Console.WriteLine("Balance: " + newBank.Accounts[6].Balance);
            Console.WriteLine("Interest rate: " + newBank.Accounts[6].InterestRate);
        }
Esempio n. 23
0
        public ActionResult DeleteConfirmed(int id)
        {
            MortgageAccount mortgageaccount = db.MortgageAccounts.Find(id);

            db.BankAccounts.Remove(mortgageaccount);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public void GetInterestAmountForMortgageAccount_MonthsCannotBeLessThanZero()
        {
            // Arrange
            Individual      person   = new Individual();
            MortgageAccount mortgage = new MortgageAccount(person, 0.3, 1000);

            // Act and Assert
            Assert.ThrowsException <ArgumentOutOfRangeException>(() => mortgage.GetInterestAmount(-2));
        }
Esempio n. 25
0
        static void Main(string[] args)
        {
            LoanAccount myLoanAccount = new LoanAccount(10.6M, 4.5M, new Individual());

            Console.WriteLine(myLoanAccount.CalculateMonthlyInterest(12));
            MortgageAccount myMortgageAccount = new MortgageAccount(1000M, 2.7M, new Company());

            Console.WriteLine(myMortgageAccount.CalculateMonthlyInterest(14));
        }
        public void MakeDepositToMortgageAccount_CannotDepositNegativeAmount()
        {
            // Arrange
            Individual      personToMakeDeposit = new Individual();
            MortgageAccount mortgage            = new MortgageAccount(personToMakeDeposit, 0.3, 1000);

            // Act and Assert
            Assert.ThrowsException <ArgumentOutOfRangeException>(() => mortgage.MakeDeposit(-2));
        }
        //
        // GET: /MortgageAccount/Delete/5

        public ActionResult Delete(int id = 0)
        {
            MortgageAccount mortgageaccount = (MortgageAccount)db.BankAccounts.Find(id);

            if (mortgageaccount == null)
            {
                return(HttpNotFound());
            }
            return(View(mortgageaccount));
        }
        public static void Main()
        {
            LoanAccount lAccount = new LoanAccount("Gosho Goshev", CustomerTypes.individual, 23423, 3);
            DepositAccount dAccount = new DepositAccount("Company", CustomerTypes.company, 44321, 1.75m);
            MortgageAccount mAccount = new MortgageAccount("Any individual", CustomerTypes.individual, -234, 2.99m);

            Console.WriteLine("Loan account interest amont for 5 months: {0}", lAccount.InterestAmount(5));
            Console.WriteLine("Deposit account interest amont for 3 months: {0}", dAccount.InterestAmount(3));
            Console.WriteLine("Mortgage account interest amont for 7 months: {0}", mAccount.InterestAmount(7));
        }
Esempio n. 29
0
        //
        // GET: /MortgageAccount/Details/5

        public ActionResult Details(int id = 0)
        {
            MortgageAccount mortgageaccount = db.MortgageAccounts.Find(id);

            if (mortgageaccount == null)
            {
                return(HttpNotFound());
            }
            return(View(mortgageaccount));
        }
        private static void TestInterestCalculations(LoanAccount a, MortgageAccount b, MortgageAccount c, DepositAccount d,
            DepositAccount e)
        {
            List<ICalculateInterest> accountInterests = new List<ICalculateInterest>() {a, b, c, d, e};

            foreach (var account in accountInterests)
            {
                Console.WriteLine("{0}, balance {1:F2}", account.GetType().Name, account.CalculateInterest(24));
            }
            Console.WriteLine();
        }
    static void Main()
    {
        LoanAccount loanAcc = new LoanAccount(new Individual("Georgi", 28, "1122334455"), 1000, 7);
        Console.WriteLine(loanAcc.CalculateInterest(6));

        DepositAccount depositAcc = new DepositAccount(new Company("SoftUni Ltd.", 1, "1122334455"), 1000, 7);
        Console.WriteLine(depositAcc.CalculateInterest(6));

        MortgageAccount mortgageAcc = new MortgageAccount(new Individual("Pesho", 20, "1122334455"), 1000, 7);
        Console.WriteLine(mortgageAcc.CalculateInterest(6));
    }
Esempio n. 32
0
        // GET api/MortgageAccount/5
        public MortgageAccount GetMortgageAccount(int id)
        {
            MortgageAccount mortgageaccount = (MortgageAccount)db.BankAccounts.Find(id);

            if (mortgageaccount == null)
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            return(mortgageaccount);
        }
Esempio n. 33
0
        //
        // GET: /MortgageAccount/Edit/5

        public ActionResult Edit(int id = 0)
        {
            MortgageAccount mortgageaccount = db.MortgageAccounts.Find(id);

            if (mortgageaccount == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ClientId       = new SelectList(db.Clients, "ClientId", "FullName", mortgageaccount.ClientId);
            ViewBag.AccountStateId = new SelectList(db.AccountStates, "AccountStateId", "Description", mortgageaccount.AccountStateId);
            return(View(mortgageaccount));
        }
 public ActionResult Edit(MortgageAccount mortgageaccount)
 {
     if (ModelState.IsValid)
     {
         db.Entry(mortgageaccount).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.AccountStateId = new SelectList(db.AccountStates, "AccountStateId", "Description", mortgageaccount.AccountStateId);
     ViewBag.ClientId       = new SelectList(db.Clients, "ClientId", "FullName", mortgageaccount.ClientId);
     return(View(mortgageaccount));
 }
Esempio n. 35
0
        //
        // GET: /MortgageAccount/Edit/5

        public ActionResult Edit(int id = 0)
        {
            MortgageAccount mortgageaccount = db.MortgageAccounts.Find(id);

            if (mortgageaccount == null)
            {
                return(HttpNotFound());
            }
            ViewBag.AccountStatusId = new SelectList(db.AccountStatus, "AccountStatusId", "Description", mortgageaccount.AccountStatusId);
            //display fullnam instead of firstname
            //ViewBag.ClientId = new SelectList(db.Clients, "ClientId", "FirstName", mortgageaccount.ClientId);
            ViewBag.ClientId = new SelectList(db.Clients, "ClientId", "FullName", mortgageaccount.ClientId);
            return(View(mortgageaccount));
        }
Esempio n. 36
0
        static void Main()
        {
            BankAccount Ivan = new DepositAccount(Customer.Individual, 975.34m, 5.3m);
            Console.WriteLine(Ivan.CalculateInterestForGivenMonth(12).ToString("f2"));
            Console.WriteLine();

            BankAccount Peter = new DepositAccount(Customer.Individual, 1637.94m, 1.3m);
            Console.WriteLine(Peter.CalculateInterestForGivenMonth(12).ToString("f2"));
            Console.WriteLine();

            BankAccount Misho = new MortgageAccount(Customer.Individual, 4457.23m, 7.3m);
            Console.WriteLine(Misho.CalculateInterestForGivenMonth(12).ToString("f2"));
            Console.WriteLine();
        }
        private static void TestDepositFunctionality(LoanAccount a, MortgageAccount b, MortgageAccount c, DepositAccount d,
            DepositAccount e)
        {
            List<IDepositMoney> accountDeposits = new List<IDepositMoney>() {a, b, c, d, e};

            foreach (var deposit in accountDeposits)
            {
                deposit.DepositMoney(1100.50m);

                Account acc = (Account) deposit;
                Console.WriteLine("{0}, balance {1:F2}", acc.GetType().Name, acc.Balance);
            }
            Console.WriteLine();
        }
Esempio n. 38
0
        public static void TestBank()
        {
            var pesho        = new Individual("Pesho");
            var peshoOffhore = new Company("PeshoOffshore");
            var depo         = new DepositAccount(1000, pesho, 5);
            var loan         = new LoanAccount(-200, peshoOffhore, 6);
            var mort         = new MortgageAccount(200, pesho, 4);

            Console.WriteLine(depo);
            Console.WriteLine(loan);
            Console.WriteLine(mort);
            Console.WriteLine(loan.CalculateInterestRate(32));
            Console.WriteLine(loan.CalculateInterestRate(1));
        }
Esempio n. 39
0
        static void Main()
        {
            IndividualCustomer cst        = new IndividualCustomer("Ivo", "Pavlev", "Andonov", "083472221");
            DepositAccount     depositAcc = new DepositAccount(cst, 1000, 0.5m);

            Console.WriteLine(depositAcc);
            //  depositAcc.WithDraw(20);
            Console.WriteLine("New balance:{0}", depositAcc.Balance);
            // depositAcc.Deposit(100000);
            Console.WriteLine("New balance:{0}", depositAcc.Balance);
            Console.WriteLine("{0:0.0}", depositAcc.CalculateInterestAmount(12));
            //------------------------------------------------------------------------------
            Console.WriteLine();

            IndividualCustomer cst1    = new IndividualCustomer("Ivo", "Pavlev", "Andonov", "083472221");
            LoanAccount        loanAcc = new LoanAccount(cst1, 1000, 1m);

            Console.WriteLine(loanAcc);
            loanAcc.Deposit(50);
            //  depositAcc.WithDraw(20);
            // depositAcc.Deposit(100000);
            Console.WriteLine("New balance:{0}", loanAcc.Balance);
            Console.WriteLine("{0:0.0}", loanAcc.CalculateInterestAmount(5));
            //------------------------------------------------------------------------------
            Console.WriteLine();

            IndividualCustomer cst2       = new IndividualCustomer("Ivo", "Pavlev", "Andonov", "083472221");
            MortgageAccount    mortageAcc = new MortgageAccount(cst2, 1000, 1m);

            Console.WriteLine(mortageAcc);
            mortageAcc.Deposit(50);
            //  depositAcc.WithDraw(20);
            // depositAcc.Deposit(100000);
            Console.WriteLine("New balance:{0}", mortageAcc.Balance);
            Console.WriteLine("{0:0.0}", mortageAcc.CalculateInterestAmount(7));

            //------------------------------------------------------------------------------
            Console.WriteLine();
            CompanyCustomer cst3        = new CompanyCustomer("Masson", "083472221");
            MortgageAccount mortageAcc1 = new MortgageAccount(cst3, 10000, 1m);

            Console.WriteLine(mortageAcc1);
            mortageAcc1.Deposit(50);
            //  depositAcc.WithDraw(20);
            // depositAcc.Deposit(100000);
            Console.WriteLine("New balance:{0}", mortageAcc1.Balance);
            Console.WriteLine("{0:0.0}", mortageAcc1.CalculateInterestAmount(24));
        }
Esempio n. 40
0
        public static void Main()
        {
            DepositAccount  depositAcc  = new DepositAccount(new Customer(CustomerType.Company), 1000m, 5.7m);
            LoanAccount     loanAcc     = new LoanAccount(new Customer(CustomerType.Individual), 5000m, 7m);
            MortgageAccount mortgageAcc = new MortgageAccount(new Customer(CustomerType.Individual), 100000m, 5m);

            Console.WriteLine(depositAcc.CalculateInterest(2) + "%");
            Console.WriteLine(loanAcc.CalculateInterest(24) + "%");
            Console.WriteLine(mortgageAcc.CalculateInterest(15) + "%");

            depositAcc.WithdrawMoney(200m);
            Console.WriteLine(depositAcc.Balance);

            loanAcc.DepositMoney(900m);
            Console.WriteLine(loanAcc.Balance);
        }
Esempio n. 41
0
        // POST api/MortgageAccount
        public HttpResponseMessage PostMortgageAccount(MortgageAccount mortgageaccount)
        {
            if (ModelState.IsValid)
            {
                db.BankAccounts.Add(mortgageaccount);
                db.SaveChanges();

                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, mortgageaccount);
                response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = mortgageaccount.BankAccountId }));
                return(response);
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }
        public ActionResult Create(MortgageAccount mortgageaccount)
        {
            mortgageaccount.SetNextAccountNumber();
            if (ModelState.IsValid)
            {
                db.BankAccounts.Add(mortgageaccount);
                db.SaveChanges();
                mortgageaccount.ChangeState();
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AccountStateId = new SelectList(db.AccountStates, "AccountStateId", "Description", mortgageaccount.AccountStateId);
            ViewBag.ClientId       = new SelectList(db.Clients, "ClientId", "FullName", mortgageaccount.ClientId);
            return(View(mortgageaccount));
        }
        public ActionResult Create(MortgageAccount mortgageaccount)
        {
            //This code has been modified
            if (ModelState.IsValid)
            {
                //Setting the mortgage account number to the next available one when creating a new mortgage account
                mortgageaccount.SetNextAccountNumber();
                db.BankAccounts.Add(mortgageaccount);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AccountStateId = new SelectList(db.AccountStates, "AccountStateId", "Description", mortgageaccount.AccountStateId);
            ViewBag.ClientId       = new SelectList(db.Clients, "ClientId", "FullName", mortgageaccount.ClientId);
            return(View(mortgageaccount));
        }
    static void Main(string[] args)
    {
        DepositAccount dep = new DepositAccount(Customers.companies, 2154);
        dep.Deposit(12);
        Console.WriteLine(dep.Balance);

        dep.CalculateInterestAmount(8);
        Console.WriteLine(dep.InterestAmount);

        MortgageAccount mort = new MortgageAccount(Customers.individuals, 56);
        mort.CalculateInterestAmount(2);
        Console.WriteLine(mort.InterestAmount);

        dep.Deposit(12313);
        Console.WriteLine(dep.Balance);

    }
Esempio n. 45
0
        public ActionResult Create(MortgageAccount mortgageaccount)
        {
            //calling the appropriate SetNext method
            mortgageaccount.SetNextAccountNumber();
            if (ModelState.IsValid)
            {
                db.BankAccounts.Add(mortgageaccount);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AccountStatusId = new SelectList(db.AccountStatus, "AccountStatusId", "Description", mortgageaccount.AccountStatusId);
            //display fullnam instead of firstname
            //ViewBag.ClientId = new SelectList(db.Clients, "ClientId", "FirstName", mortgageaccount.ClientId);
            ViewBag.ClientId = new SelectList(db.Clients, "ClientId", "FullName", mortgageaccount.ClientId);
            return(View(mortgageaccount));
        }
Esempio n. 46
0
    static void Main()
    {
        Account Ivan = new DepositAccount("Ivan", 975.34, 5.3, AccountType.Individual);

        Console.WriteLine(Ivan.CalculateInterest(12).ToString("f2"));
        Console.WriteLine();

        Account Peter = new DepositAccount("Peter", 1637.94, 1.3, AccountType.Individual);

        Console.WriteLine(Peter.CalculateInterest(12).ToString("f2"));
        Console.WriteLine();

        Account Misho = new MortgageAccount("Misho", 4457.23, 7.3, AccountType.Individual);

        Console.WriteLine(Misho.CalculateInterest(12).ToString("f2"));
        Console.WriteLine();
    }
Esempio n. 47
0
    static void Main()
    {
        Customer Pesho = new Individual("Pesho", 42);

        DepositAccount naPesho = new DepositAccount(Pesho, 1245.123M, 0.06M);

        Customer IBM = new Company("IBM", 34);

        MortgageAccount naIBM = new MortgageAccount(IBM, 12345152412, 0.23M);

        Console.WriteLine(naPesho.CalculateAmountFor(13));

        Console.WriteLine(naIBM.CalculateAmountFor(14));

        Account a = new LoanAccount(Pesho, 123123, 32);

        Console.WriteLine(a.CalculateAmountFor(6));
    }
Esempio n. 48
0
        static void Main()
        {
            var bajPesho = Customer.Individual;
            var leliaMarche = Customer.Individual;
            var mrAnderson = Customer.Individual;

            var google = Customer.Company;
            var microsoft = Customer.Company;
            var facebook = Customer.Company;

            var bajPeshoAccount = new DepositAccount(bajPesho, 200, 7);
            var leliaMarcheAccount = new MortgageAccount(leliaMarche, 200, 7);
            var mrAndersonAccount = new LoanAccount(mrAnderson, 200, 7);

            var googleAccount = new DepositAccount(google, 200, 7);
            var microsoftAccount = new MortgageAccount(microsoft, 200, 7);
            var facebookAccount = new LoanAccount(facebook, 200, 7);

            googleAccount.Withdraw(100);
               // Console.WriteLine(googleAccount.Balance);
            facebookAccount.Deposit(100);
               // Console.WriteLine(facebookAccount.Balance);

            var accounts = new List<IAccount>()
            {
                googleAccount,
                microsoftAccount,
                facebookAccount,
                bajPeshoAccount,
                leliaMarcheAccount,
                mrAndersonAccount
            };

            var sortedAccounts = accounts.OrderByDescending(account => account.Balance);

            foreach (var account in sortedAccounts)
            {
                decimal interestFirstMonths = account.CalculateInterest(3);
                decimal interest = account.CalculateInterest(13);

                Console.WriteLine("customer: {0} - balance: {1}; first months interest: {2}; interest: {3}"
                    , account.Customer, account.Balance, interestFirstMonths, interest);
            }
        }
        static void Main()
        {
            string textSeparator = new string('-', 80);

            Console.WriteLine(textSeparator);

            DepositAccount IvanAccount = new DepositAccount(new Customer("Ivan Ivanov", CustomerType.Individual), 500M, 4.6M);

            IvanAccount.Deposit(1150);
            IvanAccount.Withdraw(250);
            var interstDeposit = IvanAccount.CalculateInterest(13);

            IvanAccount.Deposit(interstDeposit);

            Console.WriteLine("Current DepositAccount balance of customer: {0} is {1:c2} ",
                              IvanAccount.Customer.CustomerName, IvanAccount.Balance);

            Console.WriteLine(textSeparator);


            LoanAccount GeorgiAccount = new LoanAccount(new Customer("Georgi Petrov", CustomerType.Individual), 1000M, 4.6M);

            GeorgiAccount.Deposit(1500);
            var interstDepositOfGosho = GeorgiAccount.CalculateInterest(9);

            GeorgiAccount.Deposit(interstDeposit);

            Console.WriteLine("Current LoanAccount balance of customer: {0} is {1:c2} ",
                              GeorgiAccount.Customer.CustomerName, GeorgiAccount.Balance);
            Console.WriteLine(textSeparator);


            MortgageAccount companyAccount = new MortgageAccount(new Customer("Maznata Mucka LTD", CustomerType.Company), 1000M, 4.6M);

            companyAccount.Deposit(1500);
            var interstDepositOfCompany = companyAccount.CalculateInterest(11);

            companyAccount.Deposit(interstDeposit);

            Console.WriteLine("Current MortgageAccount balance of customer: {0} is {1:c2} ",
                              companyAccount.Customer.CustomerName, companyAccount.Balance);
            Console.WriteLine(textSeparator);
        }
Esempio n. 50
0
        public static void ReadAccountsFromFile(List <Account> accounts, List <Customer> customers, string accountFileName)
        {
            var path = Path.Combine(Directory.GetCurrentDirectory(), accountFileName);

            var listStringLines = File.ReadLines(path).ToList();

            listStringLines.ForEach(l => {
                var listObj = l.Split(';').ToList();

                Account account;
                if (listObj[0] == typeof(MortgageAccount).Name)
                {
                    account = new MortgageAccount(
                        customers[int.Parse(listObj[1])],
                        decimal.Parse(listObj[2], CultureInfo.InvariantCulture),
                        decimal.Parse(listObj[3], CultureInfo.InvariantCulture));
                }
                else if (listObj[0] == typeof(DepositAccount).Name)
                {
                    var intiger  = int.Parse(listObj[1]);
                    var decim    = decimal.Parse(listObj[2]);
                    var intigerm = decimal.Parse(listObj[3], CultureInfo.InvariantCulture);

                    account = new DepositAccount(
                        customers[intiger],
                        decimal.Parse(listObj[2], CultureInfo.InvariantCulture),
                        decimal.Parse(listObj[3], CultureInfo.InvariantCulture));
                }
                else if (listObj[0] == typeof(LoanAccount).Name)
                {
                    account = new LoanAccount(
                        customers[int.Parse(listObj[1])],
                        decimal.Parse(listObj[2], CultureInfo.InvariantCulture),
                        decimal.Parse(listObj[3], CultureInfo.InvariantCulture));
                }
                else
                {
                    throw new ArgumentOutOfRangeException("Wrong Account type in file");
                }

                accounts.Add(account);
            });
        }
        static void Main()
        {
            var a = new LoanAccount(new Company("M-tel", "Sofia", "0987654321"), 100000, 0.01m);

            var b = new MortgageAccount(new Individual("Petar Georgiev", "Sofia", 32), 10000, 0.01m);

            var c = new MortgageAccount(new Company("M-tel", "Sofia", "0987654321"), 100000, 0.01m);

            var d = new DepositAccount(new Individual("Stamat Stamatov", "Burgas", 44), 100, 0.005m);

            var e = new DepositAccount(new Individual("Minka Stamatova", "Burgas", 42), 1000, 0.005m);

            //1. Test interest rate calculations:
            TestInterestCalculations(a, b, c, d, e);

            //2. Test deposit functionality:
            TestDepositFunctionality(a, b, c, d, e);

            //3. Test withdraw functionality:
            TestWithdrawFunctionality(d, e);
        }
Esempio n. 52
0
    static void Main()
    {
        // Customers
        Customer[] customers = new Customer[4];
        customers[0] = new IndividualCustomer("Iliqn Petrov", 59784, "0894719648");
        customers[1] = new CompanieCustomer("Kiril Iliev", 81746, "0881446720");
        customers[2] = new IndividualCustomer("Nikolai Grancharov", 91002, "0874100359");
        customers[3] = new CompanieCustomer("Kiril Slavqnov", 00147, "0886979231");

        // Accounts
        DepositAccount firstDeposit = new DepositAccount(customers[0], 3000, 0.10m, 12);

        BankAccount[] accounts = new BankAccount[5];
        accounts[0] = firstDeposit;
        accounts[1] = new LoanAccount(customers[1], 5000, 0.08m, 6);
        accounts[2] = new LoanAccount(customers[2], 5000, 0.08m, 6);
        accounts[3] = new MortgageAccount(customers[2], 22900, 0.11m, 48);
        accounts[4] = new MortgageAccount(customers[3], 22900, 0.11m, 48);

        // Print 1
        Console.ForegroundColor = ConsoleColor.Green;
        Console.WriteLine("First Print ...");
        Console.ResetColor();
        foreach (var item in accounts)
        {
            Console.WriteLine(item);
            Console.WriteLine();
        }

        // Withdraw & Deposit
        firstDeposit.Withdraw(250);
        firstDeposit.Deposit(600);

        // Print 2
        Console.ForegroundColor = ConsoleColor.Green;
        Console.WriteLine("Second Print ...");
        Console.ResetColor();
        Console.WriteLine(accounts[0]);
        Console.ReadLine();
    }
Esempio n. 53
0
 public static void Main()
 {
     var testAcount = new DepositAccount(new Company("Abc", "040304123"), 3.47m);
     Console.WriteLine(testAcount);
     Console.WriteLine(testAcount.Deposit(1200m));
     Console.WriteLine(testAcount.Withdraw(101m));
     Console.WriteLine("Interest: " + testAcount.CalculateInterest(10));
     Console.WriteLine(testAcount);
     Console.WriteLine(new string('-', 60));
     var anotherTestAccount = new MortgageAccount(new Company("Apple", "040304123"), 5);
     Console.WriteLine(anotherTestAccount);
     Console.WriteLine(anotherTestAccount.Deposit(120m));
     Console.WriteLine("Interest:" + anotherTestAccount.CalculateInterest(13));
     Console.WriteLine(anotherTestAccount);
     Console.WriteLine(new string('-', 60));
     var yetAnotherTestAccount = new LoanAccount(new Individual("Gosho","8010271234"),4.2m);
     Console.WriteLine(yetAnotherTestAccount);
     Console.WriteLine(yetAnotherTestAccount.Deposit(180m));
     Console.WriteLine("Interest: " + yetAnotherTestAccount.CalculateInterest(3));
     Console.WriteLine(yetAnotherTestAccount);
     Console.WriteLine(new string('-', 60));
 }
        public static void Main()
        {
            // These examples and most of the solutions for the classes are taken from the forum
            // I actually "did read" all of the code and changed a couple of things

            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}: {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);
            }
        }
Esempio n. 55
0
        static void Main()
        {
            ICustomer person = new Individual("Valentin Slovakov");
            ICustomer company = new Company("Simpsons Ltd.");

            IAccount mortgageAccInd = new MortgageAccount(1.3, 1204m, person, DateTime.Now);
            IAccount mortgageAccComp = new MortgageAccount(1.3, 1204m, company, DateTime.Now);
            IAccount loanAccInd = new LoanAccount(0.7, 10204m, person, DateTime.Now.AddMonths(-5));
            IAccount loanAccComp = new LoanAccount(0.2, 1054m, company, DateTime.Now);
            IAccount depositAccIndBig = new DepositAccount(2.8, 60604m, person, DateTime.Now.AddMonths(-1));
            IAccount depositAccIndSmall = new DepositAccount(4.2, 544m, person, DateTime.Now.AddMonths(-24));
            IAccount depositAccComp = new DepositAccount(4.2, 10544m, company, DateTime.Now.AddMonths(-5));

            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.CalculateInterestForPeriod(2),
                    acc.CalculateInterestForPeriod(3),
                    acc.CalculateInterestForPeriod(10),
                    acc.CalculateInterestForPeriod(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);
            }
        }
Esempio n. 57
0
        private static void Main()
        {
            ICustomer georgi = new Individual("Georgi Terziev");
            ICustomer ldsCompany = new Company("LDS Ltd.");

            IAccount mortgageAccInd = new MortgageAccount(georgi, 1024m, 5.3m);
            IAccount mortgageAccComp = new MortgageAccount(ldsCompany, 1024m, 5.3m);
            IAccount loanAccInd = new LoanAccount(georgi, 1024m, 5.3m);
            IAccount loanAccComp = new LoanAccount(ldsCompany, 1024m, 5.3m);
            IAccount depositAccIndBig = new DepositAccount(georgi, 1024m, 5.3m);
            IAccount depositAccIndSmall = new DepositAccount(georgi, 999m, 5.3m);
            IAccount depositAccComp = new DepositAccount(ldsCompany, 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.CalculateInterest(2),
                    acc.CalculateInterest(3),
                    acc.CalculateInterest(10),
                    acc.CalculateInterest(13),
                    acc.Customer.GetType().Name);
            }
        }
Esempio n. 58
0
        public static void Main()
        {
            List<IAccount> accounts = new List<IAccount>
            {
                new LoanAccount(new Company("Jurassic Pork"), 10000m, 9.4),
                new MortgageAccount(new Individual("Batman"), 0.01m, 4),
                new DepositAccount(new Individual("Bai Nakov"), 1000m, 2.6),
            };

            foreach (var account in accounts)
            {
                Console.WriteLine(account);
            }

            DepositAccount floristGumpAccount = new DepositAccount(new Company("Florist Gump"), 17500m, 5.5);
            floristGumpAccount.Withdraw(2500);
            floristGumpAccount.Deposit(1000);
            Console.WriteLine(floristGumpAccount); // Should be 16000

            Console.WriteLine();

            Console.WriteLine(floristGumpAccount.Customer.Name + " -> " + floristGumpAccount.CalcInterest(4));

            floristGumpAccount.Withdraw(15500);
            //Console.WriteLine(floristGumpAccount.CalcInterest(8)); // Should throw exception

            IAccount papaRazziPizza = new LoanAccount(new Company("Papa Razzi"), 25000m, 9.4);
            Console.WriteLine(papaRazziPizza.Customer.Name + " -> " +papaRazziPizza.CalcInterest(2));

            IAccount baiSvetlin = new MortgageAccount(new Individual("Bai Nakov"), 1000m, 2.6);
            Console.WriteLine(baiSvetlin.Customer.Name + " -> " + baiSvetlin.CalcInterest(8));
            //Console.WriteLine(baiSvetlin.Customer.Name + " -> " + baiSvetlin.CalcInterest(4)); // Should throw exception

            IAccount dejaBrewAccount = new MortgageAccount(new Company("Deja Brew Brewery"), 8000, 2.6);
            Console.WriteLine(dejaBrewAccount.Customer.Name + " -> " + dejaBrewAccount.CalcInterest(1));
        }
Esempio n. 59
-1
        public static void Main()
        {
            Bank bank = new Bank("SoftUni Bank");
            var e = bank.Accounts;
            foreach (var account in e)
            {
                Console.WriteLine(account);
            }

            try
            {
                Individual clientOne = new Individual("Pencho Pitankata", "Neyde", "1212121230");
                Company clientTwo = new Company("SoftUni", "Hadji Dimitar", "831251119", true);
                DepositAccount depositOne = new DepositAccount(clientOne, 5, 10000);
                DepositAccount depositTwo = new DepositAccount(clientOne, 2, 100, new DateTime(2000, 01, 01));
                DepositAccount depositThree = new DepositAccount(clientOne, 2, 10000, new DateTime(2008, 01, 01));
                LoanAccount loanOne = new LoanAccount(clientOne, 14, 10000, new DateTime(2003, 01, 01));
                LoanAccount loanTwo = new LoanAccount(clientTwo, 14, 10000, new DateTime(2003, 01, 01));
                MortgageAccount mortgageOne = new MortgageAccount(clientOne, 7, 100000, new DateTime(2013, 08, 01));
                MortgageAccount mortgageTwo = new MortgageAccount(clientTwo, 7, 100000, new DateTime(2014, 08, 01));
                Console.WriteLine("Deposit Account 1 Interest: {0:F2}", depositOne.Interest());
                Console.WriteLine("Deposit Account 2 Interest: {0:F2}", depositTwo.Interest());
                Console.WriteLine("Deposit Account 3 Interest: {0:F2}", depositThree.Interest());
                Console.WriteLine("Loan Account Individual Interest: {0:F2}", loanOne.Interest());
                Console.WriteLine("Loan Account Company Interest: {0:F2}", loanTwo.Interest());
                Console.WriteLine("Mortgage Account Interest: {0:F2}", mortgageOne.Interest());
                Console.WriteLine("Mortgage Account Interest: {0:F2}", mortgageTwo.Interest());
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
            }
        }