예제 #1
0
        public static void Main(string[] args)
        {
            var depositAccount = new DepositAccount(Clients.Person, 100, 20);

            Console.WriteLine(depositAccount.ShowBalance());
            try
            {
                depositAccount.Deposit(-1);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            try
            {
                Console.WriteLine(depositAccount.CalculateInterestOverPeriod(-10));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            depositAccount.Deposit(203);
            Console.WriteLine(depositAccount.ShowBalance());
            Console.WriteLine(depositAccount.CalculateInterestOverPeriod(10));
            try
            {
                Console.WriteLine($"Fail?: {depositAccount.Withdraw(100000)}");
                depositAccount.Withdraw(-10);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
예제 #2
0
        static void Main()
        {
            //Make na instance of the log system
            AccountOperationsFileLogger accountLogger = new AccountOperationsFileLogger();
            CustomerOperationsFileLogger customerLogger = new CustomerOperationsFileLogger();

            //Add subscribers to the event add/remove account/customer
            BankEngine.Instance.AccountOperation += accountLogger.AddToLog;
            BankEngine.Instance.CustomerOperation += customerLogger.AddToLog;

            //Make a list of employees
            List<Employee> mladostEmployees = new List<Employee>{
                new Employee("Pesho","Peshev","Peshev", Sex.Male,new Address("Bulgaria", "Sofia",1713,"Mladost 1A",604,'A',4,18),7812123558M,852.75M,Position.President),
                new Employee("Kiro","Kirov","Kirov", Sex.Male,new Address("Bulgaria", "Sofia",1713,"Mladost 1A",607,'A',7,32),7412123558M,852.75M,Position.Casher),
                                              };

            //Make an address
            Address locationMladost = new Address("Bulgaria", "Sofia", 1713, "bul.Al. Malinow 75");
            //Make an office with the current employee set
            Office officeMladost1A = new Office("Mladost 1A", locationMladost, mladostEmployees);

            //Add the office to the system
            BankEngine.Instance.AddLocation(officeMladost1A);

            //Add an ATM to the system
            BankEngine.Instance.AddLocation(new ATM("Mladost 1A", locationMladost, 5410, Priority.High));

            //Add an individual customer to the system
            IndividualCustomer peshoIvanov = new IndividualCustomer("IC745547", "Pesho", "Ivanov", "Ivanov", Sex.Male, new Address("Bulgaria", "Sofia", 1713, "ul.Bydnina 13"),
                                                                     8709122554M);
            //IMPORTANT
            BankEngine.Instance.AddCustomer(peshoIvanov);

            //Make an account and add it to the system
            DepositAccount peshoOODDeposit = new DepositAccount(AccountType.Corporate, AccountCurrency.EUR, AccountPeriod.Six,
                                             new CorporateCustomer("CC55475", "PeshoOOD", new Address("Bulgaria", "Sofia", 1713, "ul.Igumen 12"), "BGCT855474V",
                                                 "Pesho", "Ivanov", "Ivanov", Sex.Male, 8709122554M), 558574L);
            //IMPORTANT
            BankEngine.Instance.AddAccount(peshoOODDeposit);

            Console.WriteLine("BankEngine added new customer and account! The information was logged!");
            Console.WriteLine();

            //Deposit some money in peshoOODDeposit
            peshoOODDeposit.Deposit(5841.54M);

            //Trying to withdraw more than the balance of peshoOODDeposit
            try
            {
                Console.WriteLine("Try to withdraw more than the balance of an account:");
                peshoOODDeposit.Withdraw(6000M);
            }
            catch (InsufficientFundsException ife)
            {

                Console.WriteLine(ife.Message + "You've tried to withdraw {0} but the current balance is {1}!", ife.Amount, ife.Balance);
            }
            Console.WriteLine();
        }
예제 #3
0
        static void Main()
        {
            DepositAccount deposit = new DepositAccount(Customer.Individual, 0, 0.5m);

            deposit.Deposit(2000);
            deposit.Deposit(3000);
            deposit.Withdraw(500);
            //Console.WriteLine(deposit.Balance);
            //Console.WriteLine(deposit.CalculateInterest(5));

            Account loan = new LoanAccount(Customer.Individual, 2000, 1m);

            //Console.WriteLine(loan.CalculateInterest(5));

            Account mortgage = new LoanAccount(Customer.Individual, 30000, 1m);

            Console.WriteLine(mortgage.CalculateInterest());
        }
예제 #4
0
        static void Main()
        {
            var customer = new IndividualCustomer("Pesho", "Sofia");
            var bankAccount = new DepositAccount(customer, 30.4);

            bankAccount.Deposit(2000M);
            Console.WriteLine("Current balance: {0}",bankAccount.Balance);
            Console.WriteLine("Interest amount: {0}", bankAccount.GetInterestAmount(23));

            bankAccount.Withdraw(160.50M);
            Console.WriteLine("Current balance: {0}",bankAccount.Balance);
        }
예제 #5
0
        static void Main(string[] args)
        {
            //Customer customer = new CompanyCustomer();

            CompanyCustomer customer = new CompanyCustomer("Philips", "Munich", "Main company address", BusinessSector.Other);

            DepositAccount account = new DepositAccount(customer, 12132358.47M, 5M);

            Console.WriteLine(account.Balance);
            Console.WriteLine(account.CalculateInterest(14));
            account.Deposit(100000M);
            Console.WriteLine(account.Balance);
            account.Withdraw(500000M);
            Console.WriteLine(account.Balance);
        }
예제 #6
0
        static void Main(string[] args)
        {
            Bank fib = new Bank("First Investment Bank");
            IndividualCustomer pesho = new IndividualCustomer("Pesho");
            DepositAccount depositAccount = new DepositAccount(pesho, 2M, 0.05m);
            fib.AddCustomer(pesho);
            fib.AddAccount(depositAccount);

            depositAccount.Deposit(1000M);

            Console.WriteLine("Current blanace: " + depositAccount.Balance);

            Console.WriteLine("Interest amount: " + depositAccount.CalculateInterest(23));

            depositAccount.Withdraw(153.03M);
            Console.WriteLine("Current blanace: " + depositAccount.Balance);
        }