コード例 #1
0
ファイル: Program.cs プロジェクト: LadyMadeline/BankAccount
        static void ChangeBalance(Account user)
        {
            string signOut = "No";

            while (signOut == "No")
            {
                Console.Write("\nDo you want to replenishe (1) balance or withdraw (2) money? ");
                string userAnswer = Console.ReadLine();
                int    sum;
                Console.Write($"Enter card name ({user.GetUserCardsNames()}): ");
                string cardName = Console.ReadLine();
                Console.Write("Enter card pin: ");
                string cardPin  = Console.ReadLine();
                Card   userCard = user.GetUserCard(cardName, cardPin);
                if (userCard == null)
                {
                    Console.WriteLine("Wrong card name or pin.");
                    continue;
                }

                switch (userAnswer)
                {
                case "1":
                    Console.Write("Enter sum: ");
                    sum = Convert.ToInt32(Console.ReadLine());
                    userCard.Replenishe(sum, cardPin);
                    break;

                case "2":
                    Console.Write("Enter sum: ");
                    sum = Convert.ToInt32(Console.ReadLine());
                    userCard.Withdrow(sum, cardPin);
                    break;

                default:
                    Console.WriteLine("Wrong answer.");
                    break;
                }

                Console.WriteLine("Do you want to return to operations with account? (Yes or No) ");
                signOut = Console.ReadLine();
            }
        }