Exemplo n.º 1
0
        static void Main()
        {
            Customer Bob = new Individual("Bob", "Sideshow");
            Customer Iron = new Company("Iron", "Ltd.");

            Account depo = new Deposit("bob", 1200.00m);
            depo.NewCustomer = Bob;
            depo.DepositMoney(100.50m);
            depo.Withdraw(50.10m);
            Console.WriteLine(  depo.CalculateInterest(3.5m, 24, Bob) );

            Account lo = new Loan("Iron Ltd.", 3210000.123m);
            lo.NewCustomer = Iron;
            lo.DepositMoney(2000.001m);
            lo.Withdraw(20111.1m);
            Console.WriteLine( lo.CalculateInterest(9.10m, 52, Iron) );
        }
Exemplo n.º 2
0
        static void Main()
        {
            Company microsoft = new Company("Microsoft");
            Individual gosho = new Individual("Gosho");

            DepositAccount depositTest = new DepositAccount(microsoft, 100000, 15);
            MortgageAccount mortgageTest = new MortgageAccount(gosho, 400, 20);

            Console.WriteLine("Customer type:{0}\nCustomer name: {1}",gosho.ToString(),gosho.Name);
            Console.WriteLine("Initial mortgage account balance:{0}lv",mortgageTest.Balance);
            mortgageTest.DepositAmount(30);
            Console.WriteLine("Account balance after adding 30 lv:{0}lv\n",mortgageTest.Balance);

            Console.WriteLine("Customer type:{0}\nCustomer name: {1}",microsoft.ToString(), microsoft.Name);
            Console.WriteLine("Initial deposit account balance:{0}lv",depositTest.Balance);
            depositTest.WithdrawAmount(30000);
            Console.WriteLine("Account balance after withdrawing 30000lv:{0}lv", depositTest.Balance);
            Console.WriteLine("Account interest amount for twelve months:{0}lv\n", depositTest.CalcInterestAmount(12));
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            //Add some customers
            var Antoan = new Individual("Antoan Elenkov");
            var Georgi = new Individual("Georgi Ivanov");
            var Mtel = new Company("Mtel");
            var Telenor = new Company("Telenor");
            //Add some Accounts
            var IndividualAcc1 = new DepositAcc(Antoan, new DateTime(14, 5, 24), 1100, 0.5);
            var IndividualAcc2 = new DepositAcc(Mtel, new DateTime(12, 5, 24), 500, 0.4);
            var companyAcc1 = new DepositAcc(Georgi, new DateTime(13, 5, 24), 5500.5m, .2);
            var companyAcc2 = new LoanAcc(Telenor, new DateTime(12, 5, 24), 500, .6);

            //Initialize bank - not needed
            var FIB = new Bank("FIB", new List<Account>());
            FIB.AccountsCollection.Add(IndividualAcc1);
            FIB.AccountsCollection.Add(IndividualAcc2);
            FIB.AccountsCollection.Add(companyAcc1);
            FIB.AccountsCollection.Add(companyAcc2);

            //Individual Deposit account
            Console.WriteLine("\nIndividual Deposit account");
            Console.WriteLine("Interest rate: {0}",IndividualAcc1.CalculateInterestRate(3));
            Console.WriteLine("Balance before : {0}", IndividualAcc1.Balance);
            IndividualAcc1.Deposit(100000);
            Console.WriteLine("Balance after : {0}", IndividualAcc1.Balance);
            Console.WriteLine("Balance before : {0}", IndividualAcc1.Balance);
            IndividualAcc1.WithDraw(50000);
            Console.WriteLine("Balance after : {0}", IndividualAcc1.Balance);

            //Company Deposit account
            Console.WriteLine("\nCompany Deposit account");
            Console.WriteLine("Interest rate: {0}", companyAcc1.CalculateInterestRate(3));
            Console.WriteLine("Balance before : {0}", companyAcc1.Balance);
            companyAcc1.Deposit(6000);
            Console.WriteLine("Balance after : {0}", companyAcc1.Balance);
            Console.WriteLine("Balance before : {0}", companyAcc1.Balance);
            companyAcc1.WithDraw(100000);
            Console.WriteLine("Balance after : {0}", companyAcc1.Balance);

            //If you want, you can make some more tests :)))
        }
Exemplo n.º 4
0
        static void Main()
        {
            Bank bank = new Bank("FIB");
            var peshoCompany = new Company("Hamali");
            var pesho = new Individual("Pesho");

            Console.WriteLine(peshoCompany is Company);  //True
            Console.WriteLine(peshoCompany is Customer); //True
            Console.WriteLine(pesho is Individual);      //True
            Console.WriteLine(pesho is Customer);        //True
            Console.WriteLine(pesho is Company);         //False

            Console.WriteLine(new string('-',50));

            BankAccount[] accounts=new BankAccount[]
            {
                new DepositAccount(peshoCompany , 1300.80m,3.25m),
                new LoanAccount(pesho, 5000m, 10.8m),
                new MortgageAccount(new Company("Gosho company"),1000.80m, 4.7m),
                new DepositAccount(new Individual("Vasko","Mladost 1, bl.153", "+359888777333"),120.3m,4.14m)
            };

            foreach (var acc in accounts)
            {
                bank.AddAccount(acc);
            }

            Console.WriteLine(bank);
            Console.WriteLine(new string('-', 50));

            try
            {
                foreach (var acc in accounts)
                {
                   acc.Deposit(200);
                   Console.WriteLine(acc);
                   Console.WriteLine();
                }
            }
            catch (Exception e)
            {

                Console.WriteLine(e.Message);
            }

            try
            {
                foreach (var acc in accounts)
                {
                    acc.Deposit(-50);
                }
            }
            catch (Exception e)
            {

                Console.WriteLine(e.Message);
            }

            Console.WriteLine(new string('-', 50));

            foreach (var acc in accounts)
            {
                Console.WriteLine(acc.CalculateInterest(6));
            }

            Console.WriteLine(new string('-', 50));

            var depositAcount = accounts[0] as DepositAccount;
            depositAcount.Withdraw(800);
            Console.WriteLine(depositAcount);

            Console.WriteLine(new string('-', 50));

            try
            {
                depositAcount.Withdraw(1000);
                Console.WriteLine(depositAcount);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.WriteLine(new string('-', 50));
        }