Пример #1
0
        private void GetDataCurrent()                      //metodo para capturar cuenta corriente
        {
            int            number  = GetData();            //llamas metodo get data, asi no escribes tanto
            var            list    = data.current();       //creas una lista usando la instancia del constructor y el objeto creado global
            CurrentAccount current = new CurrentAccount(); //instancia de objeto para acceder a el

            foreach (var account in list)                  //for each para convertir el numero que el usuario digito en un objeto de la lista traida
            {
                if (number == account.AccNo)               //solo funcionara si el numero existe en las listas
                {
                    current = account;                     //cuando se cumple la condicion se crea el objeto
                }
            }
            Console.WriteLine("Bienvenido, {0}", current.HeadLine); //se trabaja con el objeto instanciado porque ya esta unificado con account
            Console.ReadKey();                                      //dale enter pa seguir
            Console.Clear();                                        //limpia pantalla despues de cada metodo, sera mucho texto si no lo haces
            MenuUser(current);                                      //mandas current al metodo menu usuario con el objeto current, usaste el foreach para este objeto en especifico
        }
Пример #2
0
        static void Main(string[] args)
        {
            Customer cus1 = new Customer("Tan Ah Kow", "2 Rich Street", "P123123", 20);
            Customer cus2 = new Customer("Kim May Mee", "89 Gold Road", "P334412", 60);

            Account a1 = new Account("S0000223", cus1, 2000);

            Console.WriteLine(a1.CalculateInterest());
            OverdraftAccount a2 = new OverdraftAccount("O1230124", cus1, 2000);

            Console.WriteLine(a2.CalculateInterest());
            CurrentAccount a3 = new CurrentAccount("C1230125", cus2, 2000);

            Console.WriteLine(a3.CalculateInterest());

            Console.WriteLine(a2.Show());
            a2.Withdraw(5000);
            //a2.TransferTo(445, a2); //OverdraftAccount does not have TransferTo method redefined, got error
            Console.WriteLine(a2.CalculateInterest());
            Console.WriteLine(a2.Show());
        }
Пример #3
0
        public Account CreateAccount(Client client, double?limit, DateTime?dateTime)
        {
            Decorator decorator = new Decorator();
            Account   resultAccount;

            if (limit != null)
            {
                resultAccount = new CreditAccount(client, (double)limit, creditLimit);
            }
            else
            {
                if (dateTime != null)
                {
                    resultAccount = new DepositAccount(client, (DateTime)dateTime, depositPercent);
                }
                else
                {
                    resultAccount = new CurrentAccount(client, currentPercent);
                }
            }

            return(resultAccount);
        }
Пример #4
0
        private static void Main(string[] args)
        {
            User nicolas = new User("Nicolas");
            User jeremie = new User("Jérémie");

            CurrentAccount nicolasCurrentAccount = new CurrentAccount(nicolas, 2000.0);

            CompanySavingsAccount nicolasCompanySavingsAccount = new CompanySavingsAccount(nicolas, 0.02);

            CurrentAccount jeremieCurrentAccount = new CurrentAccount(jeremie, 500.0);

            nicolasCurrentAccount.Credit(100.0);

            nicolasCurrentAccount.Debit(50.0);

            nicolasCompanySavingsAccount.Credit(20.0, nicolasCurrentAccount);

            nicolasCompanySavingsAccount.Credit(100.0);

            nicolasCompanySavingsAccount.Debit(20.0, nicolasCurrentAccount);

            jeremieCurrentAccount.Debit(500.0);

            jeremieCurrentAccount.Debit(200.0, nicolasCurrentAccount);

            nicolasCompanySavingsAccount.PayContributionRate();

            Console.WriteLine(Bank.ShowAllAccountsBalances());

            Console.WriteLine(nicolasCurrentAccount.ShowAccountSummary());

            Console.WriteLine(nicolasCompanySavingsAccount.ShowAccountSummary());

            Console.WriteLine(jeremieCurrentAccount.ShowAccountSummary());

            Console.ReadLine();
        }