예제 #1
0
파일: Program.cs 프로젝트: abored/exercises
        static void Main(string[] args)
        {
            Customer c = new Customer(1, "Peter Thomsen");
            BankAccount acc1 = new BankAccount(1, 8, 100);
            CheckAccount ca1 = new CheckAccount(4, 2, 1, 5, 300);
            EmployeeAccount em1 = new EmployeeAccount(5,0.5,1,5,200);

            c.AddAccount(acc1);
            c.AddAccount(ca1);
            c.AddAccount(em1);
            Console.WriteLine(c.GetTotalBalance());
            ca1.Withdraw(200);
            Console.WriteLine(c.GetTotalBalance());
            em1.Withdraw(3200);
            Console.WriteLine(em1.Disposable);
            Console.WriteLine(c.GetTotalDispose());

            Console.ReadLine();
        }
예제 #2
0
        public Account CreateAccount(AccountType type, Customer customer)
        {
            Account acc = _accountFactory.CreateAccount(type, customer);

            if (acc != null)
            {
                _accounts.Add(acc.AccountNumber, acc);
                acc.Customer = customer;
                customer.AddAccount(acc);
            }
            return(acc);
        }
예제 #3
0
        public Account CreateAccount(AccountType type, Customer customer)
        {
            IAccountFactory factory = new DefaultAccountFactory();
            Account         acc     = factory.CreateAccount(type, customer);

            if (acc != null)
            {
                _accounts.Add(acc.AccountNumber, acc);
                acc.Customer = customer;
                customer.AddAccount(acc);
            }
            return(EnableLogging ? new TracingAccount(acc)
            {
                Logger = Console.Out
            } : acc);
        }