public Account makeAccount(CardNumber cardNumber, Pin pin)
        {
            Money money = new Dollar()
            {
                amount     = 0,
                ServiceFee = 10
            };
            Balance NewAccountBalance = new Balance()
            {
                BalanceAmount = money
            };
            Account userAccount = new TransactionalAccount()
            {
                cardNumber     = cardNumber,
                pin            = pin,
                AccountBalance = NewAccountBalance
            };

            accountRepository.addAccountToRepository(userAccount);
            return(userAccount);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Account UserAccount = new TransactionalAccount();

Start:
            Console.WriteLine("1. Make account \n 2. Login");
            ConsoleKey userChoice = Console.ReadKey().Key;

            if (userChoice == ConsoleKey.D1)
            {
                UserAccount = MakeAccount();
            }
            else if (userChoice == ConsoleKey.D2)
            {
                UserAccount = Login();
            }
            if (UserAccount != null)
            {
                ConsoleKey transactionInput = ConsoleKey.D1;
                do
                {
                    Console.WriteLine("\n1- Check balance/n 2- Deposit cash/n 3- Withdraw cash/n 4- Transfer cash/n 5- Logout");
                    transactionInput = Console.ReadKey().Key;
                    switch (transactionInput)
                    {
                    case ConsoleKey.D1:
                        NonCashTransaction CheckBalanceTransaction = new CheckBalanceTransaction();
                        CheckBalanceTransaction.process(UserAccount);
                        break;

                    case ConsoleKey.D2:
                        CashTransaction DepositCashTransaction = new DepositCashTransaction();
                        Console.Write("\nAmount to deposit: ");
                        int   amountToDeposit = Int32.Parse(Console.ReadLine());
                        Money DepositAmount   = new Dollar()
                        {
                            amount = amountToDeposit
                        };

                        DepositCashTransaction.process(UserAccount, DepositAmount);
                        break;

                    case ConsoleKey.D3:
                        CashTransaction WithdrawTransaction = new WithdrawCashTransaction();
                        Console.Write("\nAmount to withdraw: ");
                        int   amountToWithdraw = Int32.Parse(Console.ReadLine());
                        Money WithdrawAmount   = new Dollar()
                        {
                            amount = amountToWithdraw
                        };
                        WithdrawTransaction.process(UserAccount, WithdrawAmount);

                        break;

                    case ConsoleKey.D4:
                        CashTransaction TransferCashTransaction = new TransferCashTransaction();
                        Console.Write("\nAmount to transfer: ");
                        int   amountToTransfer = Int32.Parse(Console.ReadLine());
                        Money TransferAmount   = new Dollar()
                        {
                            amount = amountToTransfer
                        };
                        TransferCashTransaction.process(UserAccount, TransferAmount);

                        break;

                    default:
                        Console.WriteLine("\nBreak");
                        break;
                    }
                } while (transactionInput != ConsoleKey.D5);
            }
            else
            {
                Console.WriteLine("\nAccount not found");
            }
            goto Start;
        }