Exemple #1
0
        static void Menu(FormGroup form)
        {
            bool UserContinue = true;

            while (UserContinue == true)
            {
                Console.WriteLine("What would you like to do?");

                Console.WriteLine("1 : Enter attendence for each student");
                Console.WriteLine("2 : Check student's attendance");
                Console.WriteLine("3: input a student's profile");
                Console.WriteLine("0: end the program");


                string userInput       = Console.ReadLine();
                int    userInputNumber = Convert.ToInt32(userInput);

                if (userInputNumber == 0)
                {
                    UserContinue = false;
                }
                else if (userInputNumber == 1)
                {
                    form.TakeAttendance(DateTime.Now);
                }

                else if (userInputNumber == 2)
                {
                    Console.WriteLine("Which student would you like to see the attendance of?");
                    string studentInput    = Console.ReadLine();
                    int    studentNumInput = Convert.ToInt32(studentInput);
                    form.ShowAttendance(Student[studentNumInput]);
                }

                else if (userInputNumber == 3)
                {
                    Console.WriteLine("What is the name of the student?");
                    string InputName = Console.ReadLine();

                    Console.WriteLine("When were they born? (mm/dd/yy)");
                    string   InputDoB = Console.ReadLine();
                    DateTime DoBInput = Convert.ToDateTime(InputDoB);

                    Console.WriteLine("What is their gender? (1 character)");
                    string InputGender = Console.ReadLine();
                    char   GenderInput = Convert.ToChar(InputGender);

                    form.AddStudent(InputName, DoBInput, GenderInput);
                }
            }
        }
        static public void TakeAttendance(FormGroup year12)
        {
            bool     valid = false;
            DateTime Date;

            while (valid == false)
            {
                Console.WriteLine("Which date do you want to take the attendance with?");
                string UserResponse = Console.ReadLine();

                if (DateTime.TryParse(UserResponse, out Date))
                {
                    year12.TakeAttendance(Date);
                    valid = true;
                }
                else
                {
                    Console.WriteLine("Enter it in the format DD/MM/YYYY");
                }
            }
        }