Example #1
0
        private void ShowInstanceMenu(ICard sendingCard)
        {
            bool showMenu = true;

            while (showMenu)
            {
                PrintCardOperations(sendingCard);
                bool converted = Int32.TryParse(Console.ReadLine(), out int input);

                if (converted)
                {
                    switch (input)
                    {
                    case 0:
                        showMenu = false;
                        break;

                    case 1:
                        Console.WriteLine("Type in your PIN code");
                        converted = Int32.TryParse(Console.ReadLine(), out int pin);

                        if (!sendingCard.CheckPin(pin))
                        {
                            TransactionResult(CardInfo.TransactionStatus.WrongPin);
                            break;
                        }

                        if (SendingMoney(sendingCard) == null)
                        {
                            TransactionResult(CardInfo.TransactionStatus.UnknownFailure);
                            break;
                        }

                        TransactionResult(SendingMoney(sendingCard).Status);

                        break;

                    case 2:
                        Console.WriteLine(sendingCard.GetBalance());
                        break;
                    }
                }
            }
        }