コード例 #1
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();
        }
コード例 #2
0
ファイル: Test.cs プロジェクト: Elinos/TelerikAcademy
        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);
        }
コード例 #3
0
ファイル: TestBankSystem.cs プロジェクト: SGStoyanov/SoftUni
        public static void Main()
        {
            ICustomer gosho = new IndividualCustomer("Georgi Georgiev");
            ICustomer myCompany = new CompanyCustomer("My Company Ltd.");

            IAccount mortAccInd = new MortgageAccount(gosho, 924m, 2.4m);
            IAccount mortgageAccComp = new MortgageAccount(myCompany, 888m, 7.4m);

            IAccount loanAccInd = new LoanAccount(gosho, 2048m, 4.5m);
            IAccount loanAccComp = new LoanAccount(myCompany, 512m, 6.0m);

            IAccount depositAccIndBig = new DepositAccount(gosho, 888, 6.6m);
            IAccount depositAccIndSmall = new DepositAccount(gosho, 1111m, 7.9m);
            IAccount depositAccComp = new DepositAccount(myCompany, 50326m, 4.9m);

            List<IAccount> accounts = new List<IAccount>()
            {
                mortAccInd,
                mortgageAccComp,
                loanAccInd,
                loanAccComp,
                depositAccIndBig,
                depositAccIndSmall,
                depositAccComp
            };

            foreach (var acc in accounts)
            {
                Console.WriteLine(
                    "{5} {0,-15}: {1:N2}, {2:N2}, {3:N2}, {4:N2}",
                    acc.GetType().Name,
                    acc.CalculateRate(2),
                    acc.CalculateRate(3),
                    acc.CalculateRate(10),
                    acc.CalculateRate(13),
                    acc.Customer.GetType().Name);
            }
        }
コード例 #4
0
ファイル: TestBankSystem.cs プロジェクト: ttitto/CSharp
        public static void Main()
        {
            ICustomer pesho = new IndividualCustomer("Petar Petrov");
            ICustomer agroCompany = new CompanyCustomer("Agro Company Ltd.");

            IAccount mortgageAccInd = new MortgageAccount(pesho, 1024m, 5.3m);
            IAccount mortgageAccComp = new MortgageAccount(agroCompany, 1024m, 5.3m);
            IAccount loanAccInd = new LoanAccount(pesho, 1024m, 5.3m);
            IAccount loanAccComp = new LoanAccount(agroCompany, 1024m, 5.3m);
            IAccount depositAccIndBig = new DepositAccount(pesho, 1024m, 5.3m);
            IAccount depositAccIndSmall = new DepositAccount(pesho, 999m, 5.3m);
            IAccount depositAccComp = new DepositAccount(agroCompany, 11024m, 4.3m);

            List<IAccount> accounts = new List<IAccount>()
            {
                mortgageAccInd,
                mortgageAccComp,
                loanAccInd,
                loanAccComp,
                depositAccIndBig,
                depositAccIndSmall,
                depositAccComp
            };

            foreach (var acc in accounts)
            {
                Console.WriteLine(
                    "{5} {0,-15}: {1:N2}, {2:N2}, {3:N2}, {4:N2}",
                    acc.GetType().Name,
                    acc.CalculateRate(2),
                    acc.CalculateRate(3),
                    acc.CalculateRate(10),
                    acc.CalculateRate(13),
                    acc.Customer.GetType().Name);
            }
        }
コード例 #5
0
        public static void Main()
        {
            ICustomer pesho       = new IndividualCustomer("Petar Petrov");
            ICustomer agroCompany = new CompanyCustomer("Agro Company Ltd.");

            IAccount mortgageAccInd     = new MortgageAccount(pesho, 1024m, 5.3m);
            IAccount mortgageAccComp    = new MortgageAccount(agroCompany, 1024m, 5.3m);
            IAccount loanAccInd         = new LoanAccount(pesho, 1024m, 5.3m);
            IAccount loanAccComp        = new LoanAccount(agroCompany, 1024m, 5.3m);
            IAccount depositAccIndBig   = new DepositAccount(pesho, 1024m, 5.3m);
            IAccount depositAccIndSmall = new DepositAccount(pesho, 999m, 5.3m);
            IAccount depositAccComp     = new DepositAccount(agroCompany, 11024m, 4.3m);

            List <IAccount> accounts = new List <IAccount>()
            {
                mortgageAccInd,
                mortgageAccComp,
                loanAccInd,
                loanAccComp,
                depositAccIndBig,
                depositAccIndSmall,
                depositAccComp
            };

            foreach (var acc in accounts)
            {
                Console.WriteLine(
                    "{5} {0,-15}: {1:N2}, {2:N2}, {3:N2}, {4:N2}",
                    acc.GetType().Name,
                    acc.CalculateRate(2),
                    acc.CalculateRate(3),
                    acc.CalculateRate(10),
                    acc.CalculateRate(13),
                    acc.Customer.GetType().Name);
            }
        }