Exemplo n.º 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));
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Customer petar   = new IndividualCustomer("Petar Gigov", "8412316466");
            Customer softUni = new CompanyCustomer("Software University", "BG25445644");

            Account petarDepositAccount = new DepositAccount(petar, 1000m, 3.0m);

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

            Account petarLoanAccount = new LoanAccount(petar, 10000m, 12m);

            Console.WriteLine(petarLoanAccount.CalculateInterest(4).ToString("f2"));
            Account softuniLoanAccount = new LoanAccount(softUni, 10000m, 12m);

            Console.WriteLine(softuniLoanAccount.CalculateInterest(4).ToString("f2"));
            Console.WriteLine();

            Account petarMortgageAccount = new MortgageAccount(petar, 10000m, 12m);

            Console.WriteLine(petarMortgageAccount.CalculateInterest(12).ToString("f2"));
            Account softUniMortgageAccount = new MortgageAccount(softUni, 10000m, 12m);

            Console.WriteLine(softUniMortgageAccount.CalculateInterest(12).ToString("f2"));
            Console.WriteLine();
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            Customer     pesho = new IndividualPerson("Pesho Peshev");
            Customer     globalEntertainmentOOD = new Company("Global Entertainment LTD");
            IAccountable depositAcc             = new DepositAccount(pesho, 2000m, 1.7d);
            IAccountable loanAcc    = new LoanAccount(pesho, 5000, 5.5d);
            IAccountable mortageAcc = new MortageAccount(globalEntertainmentOOD, 100000, 2.3d);

            IList <IAccountable> accounts = new List <IAccountable>()
            {
                depositAcc, loanAcc, mortageAcc
            };

            depositAcc.CalculateInterest(8d);
            depositAcc.DepositMoney(200m);
            depositAcc.WithdrawMoney(50m);
            loanAcc.CalculateInterest(20d);
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            var me = new Customer("Alex", CustomerType.Individual);
            var acc = new DepositAccount(me, 2000, 0.2);
            acc.Deposit(500);
            acc.Withdraw(600);
            Console.WriteLine("Balance: {0}", acc.Balance);
            Console.WriteLine("Interest: {0}", acc.CalculateInterest(15));
            Console.WriteLine("========");

            var loanAcc = new LoanAccount(me, 3000, 0.4);
            try
            {
                loanAcc.Withdraw(500);
            }
            catch (InvalidOperationException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemplo n.º 5
0
        static void Main()
        {
            Customer petar = new IndividualCustomer("Petar Gigov", "8412316466");
            Customer softUni = new CompanyCustomer("Software University", "BG25445644");
            Account petarDepositAccount = new DepositAccount(10000, 3.0m, petar);

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

            Account petarLoanAccount = new LoanAccount(10000, 12m, petar);
            Console.WriteLine(petarLoanAccount.CalculateInterest(4).ToString("f2"));
            Account softuniLoanAccount = new LoanAccount(10000, 12m, softUni);
            Console.WriteLine(softuniLoanAccount.CalculateInterest(4).ToString("f2"));
            Console.WriteLine();

            Account petarMortgageAccount = new MortgageAccount(10000, 12m, petar);
            Console.WriteLine(petarMortgageAccount.CalculateInterest(12).ToString("f2"));
            Account softUniMortgageAccount = new MortgageAccount(10000, 12m, softUni);
            Console.WriteLine(softUniMortgageAccount.CalculateInterest(12).ToString("f2"));
            Console.WriteLine();
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            var me  = new Customer("Alex", CustomerType.Individual);
            var acc = new DepositAccount(me, 2000, 0.2);

            acc.Deposit(500);
            acc.Withdraw(600);
            Console.WriteLine("Balance: {0}", acc.Balance);
            Console.WriteLine("Interest: {0}", acc.CalculateInterest(15));
            Console.WriteLine("========");

            var loanAcc = new LoanAccount(me, 3000, 0.4);

            try
            {
                loanAcc.Withdraw(500);
            }
            catch (InvalidOperationException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }