Exemplo n.º 1
0
        public static void ParseEvaluationInput(string input, ref List <Course> courses, int dashes, string topMessage, int courseSelection, int evaluationSelection)
        {
            switch (input)
            {
            case "D":
                CrudMethods.DeleteEvaluation(ref courses, courseSelection, evaluationSelection);
                Console.Clear();
                CourseMenu.Display(ref courses, dashes, courses[courseSelection].Code, courseSelection);
                break;

            case "E":
                CrudMethods.EditEvaluation(ref courses, courseSelection, evaluationSelection);
                Console.Clear();
                CourseMenu.Display(ref courses, dashes, courses[courseSelection].Code, courseSelection);
                break;

            case "X":
                Console.Clear();
                CourseMenu.Display(ref courses, dashes, courses[courseSelection].Code, courseSelection);
                break;

            default:
                Console.Write("incorrect selection made, please select an option above: ");
                string new_input = Console.ReadLine();
                ParseCourseInput(new_input.ToUpper(), ref courses, dashes, topMessage, courseSelection); break;
            }
        }
Exemplo n.º 2
0
        public static void ParseMainInput(string input, ref List <Course> courses, int dashes, string topMessage)
        {
            if (int.TryParse(input, out var parsedSelection))
            {
                if (parsedSelection <= 0 || parsedSelection > courses.Count)
                {
                    Error.PrintMessage("Incorrect input, try again..");
                    Console.WriteLine();
                    HelperMethods.PromptUser("Enter a command: ");
                    input = HelperMethods.GetUserSelection();
                    ParseMainInput(input, ref courses, dashes, "Grades Summary");
                }
                else
                {
                    Console.Clear();
                    CourseMenu.Display(ref courses, dashes, courses[--parsedSelection].Code, parsedSelection);
                }
            }
            else
            {
                switch (input)
                {
                case "A":
                    Course newCourse = CrudMethods.AddCourse();
                    if (newCourse != null)
                    {
                        courses.Add(newCourse);
                        Console.Clear();
                        MainMenu.Display(ref courses, dashes, topMessage);
                    }
                    else
                    {
                        ParseMainInput(input, ref courses, dashes, topMessage);
                    }
                    break;

                case "X":
                    System.Environment.Exit(1);
                    break;

                default:
                    Error.PrintMessage("Incorrect input, try again..");
                    Console.WriteLine();
                    HelperMethods.PromptUser("Enter a command: ");
                    string new_input = HelperMethods.GetUserSelection();
                    ParseMainInput(new_input, ref courses, dashes, topMessage); break;
                }
            }
        }
Exemplo n.º 3
0
        public static void ParseCourseInput(string input, ref List <Course> courses, int dashes, string topMessage, int selection)
        {
            if (int.TryParse(input, out var parsedSelection))
            {
                if (parsedSelection <= 0 || parsedSelection > courses[selection].Evaluations.Count)
                {
                    Error.PrintMessage("Incorrect input, try again..");
                    Console.WriteLine();
                    HelperMethods.PromptUser("Enter a command: ");
                    input = HelperMethods.GetUserSelection();
                    ParseCourseInput(input, ref courses, dashes, topMessage, selection);
                }
                else
                {
                    DisplayEvaluation(input, ref courses, dashes, topMessage, selection);
                }
            }
            else
            {
                switch (input)
                {
                case "A":
                    courses[selection].Evaluations.Add(CrudMethods.AddEvaluation());
                    Console.Clear();
                    CourseMenu.Display(ref courses, dashes, topMessage, selection);
                    break;

                case "D":
                    CrudMethods.DeleteCourse(ref courses, selection);
                    Console.Clear();
                    MainMenu.Display(ref courses, dashes, "Grades Summary");
                    break;

                case "X":
                    Console.Clear();
                    topMessage = "Grades Summary";
                    MainMenu.Display(ref courses, dashes, topMessage);
                    break;

                default:
                    Error.PrintMessage("Incorrect input, try again..");
                    Console.WriteLine();
                    HelperMethods.PromptUser("Enter a command: ");
                    string new_input = Console.ReadLine();
                    ParseCourseInput(new_input.ToUpper(), ref courses, dashes, topMessage, selection); break;
                }
            }
        }
Exemplo n.º 4
0
        public static void ParseUserInput(char c, int selection, string input, ref List <Course> courses, string topMessage, int dashes)
        {
            GetCourseSelection(ref c, ref selection, input);

            if (Char.IsDigit(c) && selection >= 0)
            {
                if (selection < 0 || selection >= courses.Count)
                {
                    Error.PrintMessage("Incorrect input, try again..");
                    HelperMethods.PromptUser("Enter a command: ");
                    input = HelperMethods.GetUserSelection();
                    ParseUserInput(c, selection, input, ref courses, topMessage, dashes);
                }
                Console.Clear();
                topMessage = courses[selection].Code;
                CourseMenu.Display(ref courses, dashes, topMessage, selection);
            }
            else
            {
                ParseMethods.ParseMainInput(input, ref courses, dashes, topMessage);
            }
        }