예제 #1
0
        public void SetOption(int option)
        {
            CalculateMath CalcMath = new CalculateMath();

            switch (option)
            {
            case 1:
                CalcMath.Add();
                GoBackToMenu();
                break;

            case 2:
                CalcMath.Sub();
                GoBackToMenu();
                break;

            case 3:
                CalcMath.Div();
                GoBackToMenu();
                break;

            case 4:
                CalcMath.Mul();
                GoBackToMenu();
                break;

            case 5:
                break;

            default:
                Console.WriteLine("Invalid input");
                Console.ReadKey();
                break;
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            bool          power  = true;
            bool          parsed = false;
            string        option;
            int           intOption;
            CalculateMath CalcMath = new CalculateMath();
            Hjalpmetoder  Hjalp    = new Hjalpmetoder();

            while (power == true)
            {
                do
                {
                    Console.Clear();
                    Hjalp.GetMenu();
                    option = Console.ReadLine();
                    parsed = int.TryParse(option, out intOption);
                    if (string.IsNullOrEmpty(option))
                    {
                        Console.WriteLine("Invalid input.");
                    }
                    else if (!parsed)
                    {
                    }
                    else
                    {
                        intOption = int.Parse(option);
                    }
                } while (string.IsNullOrEmpty(option) && parsed == false);
                power = Hjalp.TurnOff(intOption);

                Hjalp.SetOption(intOption);
            }
        }