Exemple #1
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));
        }
        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);
        }
Exemple #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);
        }
    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));
    }
Exemple #5
0
        static void Main()
        {
            IndividualCustomer Bobo  = new IndividualCustomer("Bobo");
            CompanyCustomer    Komfo = new CompanyCustomer("Komfo");

            DepositAccount firstDeposit  = new DepositAccount(Bobo, 800, 15);
            LoanAccoint    secondDeposit = new LoanAccoint(Komfo, 2299, 19);

            Console.WriteLine("Balance {0}: {1:#.##} lv.; Interest: {2:0.##}"
                              , firstDeposit.Customer.Name, firstDeposit.Balance, firstDeposit.CalculateInterest(12));

            firstDeposit.DepositMoney(600);
            Console.WriteLine("Balance {0}: {1:#.##} lv.; Interest: {2:0.##}"
                              , firstDeposit.Customer.Name, firstDeposit.Balance, firstDeposit.CalculateInterest(12));


            Console.WriteLine("Balance {0}: {1:#.##} lv.; Interest: {2:0.##}"
                              , secondDeposit.Customer.Name, secondDeposit.Balance, secondDeposit.CalculateInterest(2));

            Console.WriteLine();
            Console.WriteLine("Balance {0}: {1:#.##} lv.; Interest: {2:0.##}"
                              , secondDeposit.Customer.Name, secondDeposit.Balance, secondDeposit.CalculateInterest(6));

            MortgageAccount death = new MortgageAccount(Bobo, 750, 15);
            MortgageAccount metal = new MortgageAccount(Komfo, 1000, 15);

            Console.WriteLine("Balance {0}: {1:#.##} lv.; Interest: {2:0.##}"
                              , death.Customer.Name, death.Balance, death.CalculateInterest(6));
            Console.WriteLine("Balance {0}: {1:#.##} lv.; Interest: {2:0.##}"
                              , death.Customer.Name, death.Balance, death.CalculateInterest(7));
            Console.WriteLine();

            Console.WriteLine("Balance {0}: {1:#.##} lv.; Interest: {2:0.##}"
                              , metal.Customer.Name, metal.Balance, metal.CalculateInterest(12));
            Console.WriteLine("Balance {0}: {1:#.##} lv.; Interest: {2:0.##}"
                              , metal.Customer.Name, metal.Balance, metal.CalculateInterest(24));
        }
Exemple #6
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);
        }
Exemple #7
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();
    }
        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);
        }
Exemple #9
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()
        {
            // 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);
        }