Ejemplo n.º 1
0
        static void Main()
        {
            Customer kircho = new Individual("a001", "Kiro", "8503122535", new DateTime(1990, 10, 25));

            Customer firmata = new Company("a002", "p2p", "503122535");

            Console.WriteLine(firmata is Individual);
            Console.WriteLine(kircho is Individual);

            BankAccount mortgageAccTest = new MortgageAccount(200.2m, 0.6m, kircho);
            BankAccount mortgageAccTest1 = new MortgageAccount(200.2m, 0.6m, firmata);

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

            BankAccount loanAccTest = new LoanAccount(200.2m, 0.6m, kircho);
            BankAccount loanAccTest1 = new LoanAccount(200.2m, 0.6m, firmata);

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

            BankAccount depositAccTest = new DepositAccount(3200.2m, 0.6m, kircho);
            BankAccount depositAccTest1 = new DepositAccount(1200.2m, 0.6m, firmata);

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

            depositAccTest.Deposit(200);
            Console.WriteLine(depositAccTest.Balance);
            var depositAcc = depositAccTest as DepositAccount;
            depositAcc.Withdraw(300);
            Console.WriteLine(depositAcc.Balance);
        }
Ejemplo n.º 2
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));
        }
        static void Main()
        {
            Customer kircho = new Individual("a001", "Kiro", "8503122535", new DateTime(1990, 10, 25), Gender.Male);

            Customer firmata = new Company("a002", "p2p", "503122535");

            Console.WriteLine(firmata is Individual);
            Console.WriteLine(kircho is Individual);

            BankAccount mortgageAccTest  = new MortgageAccount(200.2m, 0.6m, kircho);
            BankAccount mortgageAccTest1 = new MortgageAccount(200.2m, 0.6m, firmata);

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

            BankAccount loanAccTest  = new LoanAccount(200.2m, 0.6m, kircho);
            BankAccount loanAccTest1 = new LoanAccount(200.2m, 0.6m, firmata);

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

            BankAccount depositAccTest  = new DepositAccount(3200.2m, 0.6m, kircho);
            BankAccount depositAccTest1 = new DepositAccount(1200.2m, 0.6m, firmata);

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

            depositAccTest.Deposit(200);
            Console.WriteLine(depositAccTest.Balance);
            var depositAcc = depositAccTest as DepositAccount;

            depositAcc.Withdraw(300);
            Console.WriteLine(depositAcc.Balance);
        }
Ejemplo n.º 4
0
        public static void Main()
        {
            Customer       ivan = new IndividualCustomer("Ivan");
            DepositAccount ivanDepositAccount = new DepositAccount(ivan, 500M, 4M);

            Console.WriteLine(ivanDepositAccount.Client.Name);
            Console.WriteLine(ivanDepositAccount.InterestRate);
            ivanDepositAccount.Deposit(100M);
            Console.WriteLine(ivanDepositAccount.Balance);
            ivanDepositAccount.Withdraw(100);
            Console.WriteLine(ivanDepositAccount.Balance);
            Console.WriteLine(ivanDepositAccount.CalculateInterest(5));
            Console.WriteLine(ivanDepositAccount);

            Customer        company = new CompanyCustomer("Company");
            MortgageAccount companyMortgageAcount = new MortgageAccount(company, 100000M, 1.5M);

            Console.WriteLine(companyMortgageAcount.Client.Name);
            Console.WriteLine(companyMortgageAcount);
            companyMortgageAcount.Deposit(10000);
            Console.WriteLine(companyMortgageAcount.Balance);
            companyMortgageAcount.CalculateInterest(20);

            LoanAccount companyLoanAccount = new LoanAccount(company, 25000M, 5M);

            Console.WriteLine(companyLoanAccount);
            companyLoanAccount.Deposit(5000.50M);
            Console.WriteLine(companyLoanAccount.CalculateInterest(30));
            Console.WriteLine(companyLoanAccount);
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            var b = new Bank("BCR");

            var c1 = new Individual();

            var d = new DepositAccount(b, c1, 1000, 3.85m, 12);

            Console.WriteLine(d.CalculateInterest());


            var l = new LoanAccount(b, c1, 1000, 3.5m, 12);

            Console.WriteLine(l.CalculateInterest());

            var c2 = new Company();
            var m  = new MortgageAccount(b, c2, 1500, 3.8m, 36);

            Console.WriteLine(m.CalculateInterest());
        }
Ejemplo n.º 6
0
        static void Main()
        {
            var individual = new Individual("Petar Petrov");
            var company    = new Company("Mobiltel EAD");

            var depositAccountInd  = new DepositAccount(3, 600, individual);
            var depositAccountComp = new DepositAccount(2, 6000, company);

            depositAccountInd.Deposit(50);
            depositAccountComp.Withdraw(1000);
            Console.WriteLine($"Individual balance in deposit account before interest: {depositAccountInd.Balance:F2}.");
            Console.WriteLine($"Company balance in deposit account before interest: {depositAccountComp.Balance:F2}.");

            var individualInterest = depositAccountInd.CalculateInterest(12);
            var companyInterest    = depositAccountComp.CalculateInterest(12);

            Divide();
            Console.WriteLine($"Individual balance after 12 months interest in deposit account: {individualInterest:F2}. (less than 1000 balance => no interest)");
            Console.WriteLine($"Company balance after 12 months interest in deposit account: {companyInterest:F2}.");
            var loanAcccountInd  = new LoanAccount(7, 650, individual);
            var loanAcccountComp = new LoanAccount(9, 5000, company);

            individualInterest = loanAcccountInd.CalculateInterest(12);
            companyInterest    = loanAcccountComp.CalculateInterest(12);
            Divide();
            Console.WriteLine($"Individual balance after 12 months interest in loan account: {individualInterest:F2}.");
            Console.WriteLine($"Company balance after 12 months interest in loan account: {companyInterest:F2}.");

            var mortageAccountInd  = new MortgageAccount(7, 650, individual);
            var mortageAccountComp = new MortgageAccount(9, 5000, company);

            individualInterest = mortageAccountInd.CalculateInterest(12);
            companyInterest    = mortageAccountComp.CalculateInterest(12);
            Divide();
            Console.WriteLine($"Individual balance after 12 months interest in mortage account: {individualInterest:F2}.");
            Console.WriteLine($"Company balance after 12 months interest in mortage account: {companyInterest:F2}.");
        }
        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);
        }