Exemple #1
0
        public void Open(AccountType accountType, decimal sum,
                         AccountStateHandler addSumHandler, AccountStateHandler withdrawSumHandler,
                         AccountStateHandler calculationHandler, AccountStateHandler closeAccountHandler,
                         AccountStateHandler openAccountHandler)
        {
            T newAccount = null;

            switch (accountType)
            {
            case AccountType.Ordinary:
                newAccount = new DemandAccount(sum, 1) as T;
                break;

            case AccountType.Deposit:
                newAccount = new DepositAccount(sum, 40) as T;
                break;
            }

            if (newAccount == null)
            {
                throw new Exception("Error creating account");
            }

            accounts.Add(newAccount);

            newAccount.Added      += addSumHandler;
            newAccount.Withdrawed += withdrawSumHandler;
            newAccount.Closed     += closeAccountHandler;
            newAccount.Opened     += openAccountHandler;
            newAccount.Calculated += calculationHandler;

            newAccount.Open();
        }
Exemple #2
0
        public void Open(AccountType accountType, decimal sum,
                         AccountStateHandler addSumHandler,
                         AccountStateHandler withdrawSumHandler,
                         AccountStateHandler calculationHandler,
                         AccountStateHandler closeAccoundHandler,
                         AccountStateHandler openAccountHandler)
        {
            T newAccount = null;

            switch (accountType)
            {
            case AccountType.Ordinary:
            {
                newAccount = new DemandAccount(sum, 1) as T;
                break;
            }

            case AccountType.Deposit:
            {
                newAccount = new DepositAccount(sum, 40) as T;
                break;
            }
            }

            if (newAccount == null)
            {
                throw new Exception("Ошибка создания счета.");
            }

            if (accounts == null)
            {
                accounts = new T[] { newAccount };
            }
            else
            {
                T[] tempAccounts = new T[accounts.Length + 1];

                for (int i = 0; i < accounts.Length; i++)
                {
                    tempAccounts[i] = accounts[i];
                }
                tempAccounts[tempAccounts.Length - 1] = newAccount;
                accounts = tempAccounts;
            }

            newAccount.Added      += addSumHandler;
            newAccount.Withdrawed += withdrawSumHandler;
            newAccount.Opened     += openAccountHandler;
            newAccount.Closed     += closeAccoundHandler;
            newAccount.Calculated += calculationHandler;

            newAccount.Open();
        }
Exemple #3
0
        // the method for creating of account
        public void Open(AccountType accountType, decimal sum, AccountStateHandler addSumHandler,
                         AccountStateHandler takeSumHandler, AccountStateHandler calculationHandler,
                         AccountStateHandler closeAcccountHandler, AccountStateHandler openAccountHandler
                         )
        {
            T newAccount = null;

            switch (accountType)
            {
            case AccountType.Ordinary:
                newAccount = new DemandAccount(sum, 1) as T;
                break;

            case AccountType.Deposit:
                newAccount = new DepositAccount(sum, 40) as T;
                break;
            }

            if (newAccount == null)
            {
                throw new Exception("Помилка створення рахунку");
            }

            // add the new account to massif of accounts
            if (accounts == null)
            {
                accounts = new T[] { newAccount }
            }
            ;
            else
            {
                T[] tempAccounts = new T[accounts.Length + 1];
                for (int i = 0; i < accounts.Length; i++)
                {
                    tempAccounts[i] = accounts[i];
                }
                tempAccounts[tempAccounts.Length - 1] = newAccount;
                accounts = tempAccounts;
            }

            // setting up an account event handler
            newAccount.Added      += addSumHandler;
            newAccount.Take       += takeSumHandler;
            newAccount.Closed     += closeAcccountHandler;
            newAccount.Opened     += openAccountHandler;
            newAccount.Calculated += calculationHandler;

            newAccount.Open();
        }
Exemple #4
0
        // метод створення рахунку
        public void Open(AccountType accountType, decimal sum,
                         AccountStateHandler addSumHandler, AccountStateHandler withdrawSumHandler,
                         AccountStateHandler calculationHandler, AccountStateHandler closeAccountHandler,
                         AccountStateHandler printAccountsHandler, AccountStateHandler openAccountHandler)
        {
            T newAccount = null;

            switch (accountType)
            {
            case AccountType.Ordinary:
                newAccount = new DemandAccount(sum, 1) as T;
                break;

            case AccountType.Deposit:
                newAccount = new DepositAccount(sum, 40) as T;
                break;
            }

            if (newAccount == null)
            {
                throw new Exception("Помилка створення рахунку");
            }
            // додаємо новий рахунок у масив рахунків
            if (accounts == null)
            {
                accounts = new T[] { newAccount }
            }
            ;
            else
            {
                T[] tempAccounts = new T[accounts.Length + 1];

                for (int i = 0; i < accounts.Length; i++)
                {
                    tempAccounts[i] = accounts[i];
                }
                tempAccounts[tempAccounts.Length - 1] = newAccount;
                accounts = tempAccounts;
            }
            // встановлення обробників подій рахунків
            newAccount.Added      += addSumHandler;
            newAccount.Withdrawed += withdrawSumHandler;
            newAccount.Closed     += closeAccountHandler;
            newAccount.Opened     += openAccountHandler;
            newAccount.Calculated += calculationHandler;
            newAccount.Printed    += printAccountsHandler;

            newAccount.Open();
        }
Exemple #5
0
        // метод создания счета
        public void Open(AccountType accountType, decimal sum,
                         AccountStateHandler addSumHandler,
                         AccountStateHandler withdrawSumHandler,
                         AccountStateHandler calculationHandler,
                         AccountStateHandler closeAccountHandler,
                         AccountStateHandler openAccountHandler)
        {
            T newAccount = null;

            switch (accountType)
            {
            case AccountType.Ordinary:
                newAccount = new DemandAccount(sum, 1) as T;
                break;

            case AccountType.Deposit:
                newAccount = new DepositAccount(sum, 40) as T;
                break;
            }

            if (newAccount == null)
            {
                throw new Exception("Ошибка создания счета");
            }
            // добавляем новый счет в массив счетов
            if (accounts == null)
            {
                accounts = new T[] { newAccount }
            }
            ;
            else
            {
                T[] tempAccounts = new T[accounts.Length + 1];
                for (int i = 0; i < accounts.Length; i++)
                {
                    tempAccounts[i] = accounts[i];
                }
                tempAccounts[tempAccounts.Length - 1] = newAccount;
                accounts = tempAccounts;
            }
            // установка обработчиков событий счета
            newAccount.Added      += addSumHandler;
            newAccount.Withdrawed += withdrawSumHandler;
            newAccount.Closed     += closeAccountHandler;
            newAccount.Opened     += openAccountHandler;
            newAccount.Calculated += calculationHandler;

            newAccount.Open();
        }
Exemple #6
0
        // метод создания счета
        public void Open(AccountType accountType, decimal sum, AccountStateHandler addSumHandler, AccountStateHandler withdrawSumHandler,
            AccountStateHandler calculationHandler, AccountStateHandler closeAccountHandler, AccountStateHandler openAccountHandler)
        {
            T newAccount = null;

            switch (accountType)
            {
                case AccountType.Ordinary:
                    newAccount = new DemandAccount(sum, 1) as T;
                    break;
                case AccountType.Deposit:
                    newAccount = new DepositAccount(sum, 40) as T;
                    break;
            }
        }
Exemple #7
0
        public void Open(AccountType accountType, decimal sum,
                         AccountStateHandler addSumHandler, AccountStateHandler withdrawSumHandler,
                         AccountStateHandler calculationHandler, AccountStateHandler closeAccountHandler,
                         AccountStateHandler openAccountHandler)//create account method
        {
            T newAccount = null;

            switch (accountType)
            {
            case AccountType.Ordinary:
                newAccount = new DemandAccount(sum, 1) as T;
                break;

            case AccountType.Deposit:
                newAccount = new DepositAccount(sum, 40) as T;
                break;
            }

            if (newAccount == null)
            {
                throw new Exception("Ошибка создания счета");
            }
            //add a new account to accounts array
            if (accounts == null)
            {
                accounts = new T[] { newAccount }
            }
            ;
            else
            {
                T[] tempAccounts = new T[accounts.Length + 1];
                for (int i = 0; i < accounts.Length; i++)
                {
                    tempAccounts[i] = accounts[i];
                }
                tempAccounts[tempAccounts.Length - 1] = newAccount;
                accounts = tempAccounts;
            }
            //setting the event handlers up
            newAccount.Added      += addSumHandler;
            newAccount.Withdrawed += withdrawSumHandler;
            newAccount.Closed     += closeAccountHandler;
            newAccount.Opened     += openAccountHandler;
            newAccount.Calculated += calculationHandler;

            newAccount.Open();
        }
Exemple #8
0
        public void Open(AccountType accountType, decimal sum,
                         AccountStateHandler add, AccountStateHandler withdraw,
                         AccountStateHandler open, AccountStateHandler close,
                         AccountStateHandler calculate)
        {
            T newAccount = null;

            switch (accountType)
            {
            case AccountType.Ordinary:
                newAccount = new DemandAccount(sum, 10) as T;
                break;

            case AccountType.Deposit:
                newAccount = new DepositAccount(sum, 20) as T;
                break;
            }

            if (newAccount == null)
            {
                throw new Exception("Error create account!");
            }
            if (accounts == null)
            {
                accounts = new T[] { newAccount }
            }
            ;
            else
            {
                T[] tempAccounts = new T[accounts.Length + 1];
                for (int i = 0; i < accounts.Length; ++i)
                {
                    tempAccounts[i] = accounts[i];
                }
                tempAccounts[tempAccounts.Length] = newAccount;
                accounts = tempAccounts;
            }

            newAccount.Added      += add;
            newAccount.Calculated += calculate;
            newAccount.Closed     += close;
            newAccount.Opened     += open;
            newAccount.WithDraw   += withdraw;

            newAccount.Open();
        }
Exemple #9
0
        public void Open(AccountType accountType, double sum,
                         AccountStateHandler addSumHandler, AccountStateHandler withdrawSumHandler,
                         AccountStateHandler calculationHandler, AccountStateHandler closeAccountHandler,
                         AccountStateHandler openAccountHandler, AccountStateHandler transferHandler)
        {
            T newAccount = null;

            switch (accountType)
            {
            case AccountType.Ordinary:
                newAccount = new DemandAccount(sum, 1) as T;
                break;

            case AccountType.Deposit:
                newAccount = new DepositAccount(sum, 40) as T;
                break;
            }

            if (newAccount == null)
            {
                throw new Exception("Error creating account");
            }
            if (accounts == null)
            {
                accounts = new T[] { newAccount }
            }
            ;
            else
            {
                var tempAccounts = new T[accounts.Length + 1];
                for (var i = 0; i < accounts.Length; i++)
                {
                    tempAccounts[i] = accounts[i];
                }
                tempAccounts[tempAccounts.Length - 1] = newAccount;
                accounts = tempAccounts;
            }
            newAccount.Added      += addSumHandler;
            newAccount.Withdrawed += withdrawSumHandler;
            newAccount.Closed     += closeAccountHandler;
            newAccount.Opened     += openAccountHandler;
            newAccount.Calculated += calculationHandler;
            newAccount.Transfered += transferHandler;

            newAccount.Open();
        }
Exemple #10
0
        public void Open(AccountType accountType, decimal sum)
        {
            T newAccount = null;

            switch (accountType)
            {
            case AccountType.Ordinary:
                newAccount = new DemandAccount(sum, 1) as T;
                break;

            case AccountType.Deposit:
                newAccount = new DepositAccount(sum, 40) as T;
                break;
            }

            if (newAccount == null)
            {
                throw new Exception("Error creating account");
            }

            if (accounts == null)
            {
                accounts = new T[] { newAccount };
            }
            else
            {
                T[] tempAccounts = new T[accounts.Length + 1];
                for (int i = 0; i < accounts.Length; i++)
                {
                    tempAccounts[i] = accounts[i];
                }
                tempAccounts[tempAccounts.Length - 1] = newAccount;
                accounts = tempAccounts;
            }
            newAccount.Added      += AddSumHandler;
            newAccount.Withdrawed += WithdrawSumHandler;
            newAccount.Closed     += CloseAccountHandler;
            newAccount.Opened     += OpenAccountHandler;
            newAccount.Calculated += CalculationHandler;

            newAccount.Open();
        }
Exemple #11
0
        public void Open(AccountType accounttype, decimal sum, AccountStateHandler addSumHandler, AccountStateHandler withdrawSumHandler, AccountStateHandler calculateHandler, AccountStateHandler closeAccountHandler, AccountStateHandler openAccountHandler)
        {
            T newAccount = null;

            switch (accounttype)
            {
            case AccountType.Ordinary:
                newAccount = new DemandAccount(sum, 1) as T;
                break;

            case AccountType.Deposit:
                newAccount = new DemandAccount(sum, 40) as T;
                break;
            }
            if (newAccount == null)
            {
                throw new Exception("Ошибка создания счета");
            }
            if (Accounts == null)
            {
                Accounts = new T[] { newAccount };
            }
            else
            {
                T[] TempAccounts = new T [Accounts.Length + 1];
                for (int x = 0; x < Accounts.Length; x++)
                {
                    TempAccounts[x] = Accounts[x];
                }
                TempAccounts[Accounts.Length - 1] = newAccount;
                Accounts = TempAccounts;
            }
            newAccount.Added      += addSumHandler;
            newAccount.Withdrawed += withdrawSumHandler;
            newAccount.Calculated += calculateHandler;
            newAccount.Closed     += closeAccountHandler;
            newAccount.Opened     += openAccountHandler;
            newAccount.Open();
        }