Beispiel #1
0
        public static void MenuS(Account SA)
        {
            string optionS;

            Regex Rgx = new Regex(@"\d+\.\d+");

            do
            {
                Console.WriteLine("You accessed the Savings page:");

                Console.WriteLine(String.Format("A. Deposit\nB. Withdraw\nC. Close + Report\nR. Go Back"));
                optionS = Console.ReadLine().ToUpper();

                switch (optionS)
                {
                case "A":
                    Console.WriteLine("Enter the amount you want to deposit:");
                    string stringAmountD = Console.ReadLine();
                    if (!(Rgx.IsMatch(stringAmountD)))
                    {
                        throw new FormatException("The number you entered is not acceptable");
                    }
                    double.TryParse(stringAmountD, out double userAmountD);
                    SA.MakeDeposit(userAmountD);
                    break;

                case "B":
                    Console.WriteLine("Enter the amount you want to withdraw:");
                    string stringAmountW = Console.ReadLine();
                    if (!(Rgx.IsMatch(stringAmountW)))
                    {
                        throw new FormatException("The number you entered is not acceptable");
                    }
                    double.TryParse(stringAmountW, out double userAmountW);
                    SA.MakeWithdrawl(userAmountW);
                    break;

                case "C":
                    Console.WriteLine(SA.CloseAndReport());
                    Console.WriteLine("The values yield a change of: {0:F2}%", SA.GetPercentageChange());
                    break;

                case "R":
                    break;

                default:
                    throw new InvalidOperationException("That's not what I'm looking for...");
                }
            }while (optionS != "R");
        }