Пример #1
0
        //Return info about the list chosen by the user
        public string ChosenList(string input)
        {
            if (_studentchosen == true)
            {
                //Default value to display if user doesn't give an existing 'matricule'
                string             displaystudent = "";
                ReturnStudentsInfo studentsinfo   = new ReturnStudentsInfo(this._studentslist, this._teacherslist, this._activitieslist, input);
                displaystudent = studentsinfo.ToString();
                if (displaystudent != "")
                {
                    return(displaystudent);
                }
                //Error message displayed when the user doesn't give an existing 'matricule'
                return("Veuillez entrer l'un des matricules existants\n");
            }

            else if (_teacherchosen == true)
            {
                string         displayteacher  = "";
                List <Teacher> newteacherslist = new List <Teacher>();
                displayteacher = new ReturnTeachersinfo(newteacherslist, this._studentslist, input).ToString();
                if (displayteacher != "")
                {
                    return(displayteacher);
                }
                //Error message displayed when the user doesn't give an existing trigram
                return("Veuillez entrer un trigramme existant\n");
            }

            else if (_activitychosen == true)
            {
                string displayactivities = "";

                ReturnActivities activities = new ReturnActivities(this._teacherslist);
                //Analyze the list of activities for a match between the input and one of the activities
                foreach (Activity eachactivity in activities.List())
                {
                    if (eachactivity.Code == input)
                    {
                        displayactivities += eachactivity.DisplayBook();
                    }
                }
                if (displayactivities != "")
                {
                    return(displayactivities);
                }
                //Error message displayed when the user doesn't give an existing Activity code
                return("Veuillez entrer l'un des codes d'activites existants\n");
            }
            return("Error");
        }
Пример #2
0
        public override string ToString()
        {
            string displaystudent = "";


            foreach (Student student in this._studentslist)
            {
                //Test if already have given evaluations to the student in the list
                if (student.is_evaluated == false)
                {
                    if (student.Matricule.ToString() == this._input)
                    {
                        string line;
                        System.IO.StreamReader evaluations = new System.IO.StreamReader("Evaluations.txt");
                        while ((line = evaluations.ReadLine()) != null)
                        {
                            string[] evaluation = line.Split(new Char[] { ';' });
                            //On each line of the document, the Student's matricule is the third element
                            if (evaluation[2] == student.Matricule.ToString())
                            {
                                if (this._activitieslist.Count == 0)
                                {
                                    ReturnActivities result = new ReturnActivities(this._teacherslist);
                                    this._activitieslist = result.List();
                                }


                                foreach (Activity eachactivity in this._activitieslist)
                                {
                                    //The "Code" of each Activity is the first element of each line of the document
                                    if (eachactivity.Code == evaluation[0])
                                    {
                                        int value;
                                        //Create different object given that evaluation can be string or number
                                        if (int.TryParse(evaluation[1], out value))
                                        {
                                            Cote cotestudent = new Cote(eachactivity,
                                                                        Convert.ToInt32(evaluation[1]));
                                            student.Add(cotestudent);
                                        }
                                        else
                                        {
                                            Appreciation studentappreciation = new Appreciation(eachactivity,
                                                                                                evaluation[1]);
                                            student.Add(studentappreciation);
                                        }
                                    }
                                }
                            }
                        }
                        displaystudent = student.Bulletin();
                    }
                }
                else
                {
                    if (student.Matricule.ToString() == this._input)
                    {
                        displaystudent += student.Bulletin();
                    }
                }
            }

            return(displaystudent);
        }
Пример #3
0
        //Displays the second menu for all the possibilities
        public override string ToString()
        {
            switch (this._input)
            {
            //Displays the students list
            case "1":
                _studentchosen  = true;
                _teacherchosen  = false;
                _activitychosen = false;

                string studentdisplay = "\nVoici la liste des etudiants\n";
                string line;
                if (this._studentslist.Count == 0)
                {
                    System.IO.StreamReader allStudents = new System.IO.StreamReader("Students.txt");
                    while ((line = allStudents.ReadLine()) != null)
                    {
                        string[] splitstudents = line.Split(new Char[] { ';' });
                        Student  student       = new Student(splitstudents[0], splitstudents[1], Convert.ToInt32(splitstudents[2]));
                        this._studentslist.Add(student);
                    }
                }
                //Displays a number in front of the possible choices, starting at 1
                int counter = 1;
                foreach (Student eachstudent in this._studentslist)
                {
                    studentdisplay += string.Format("{0}/ {1}, Matricule : {2}\n", counter, eachstudent.DisplayName(), eachstudent.Matricule);
                    counter++;
                }

                return(studentdisplay + "\nChoisir un etudiant pour afficher son bulletin en donnant le numero de son matricule ou taper B pour revenir au menu principal.");

            //Displays the list of teachers
            case "2":
                _studentchosen  = false;
                _teacherchosen  = true;
                _activitychosen = false;
                string teacherdisplay = "\nVoici la liste des enseignants\n";
                this._teacherslist = new List <Teacher>();
                if (this._teacherslist.Count == 0)
                {
                    System.IO.StreamReader allTeachers = new System.IO.StreamReader("Teachers.txt");
                    while ((line = allTeachers.ReadLine()) != null)
                    {
                        string[] splitteachers = line.Split(new Char[] { ';' });
                        Teacher  teacher       = new Teacher(splitteachers[0], splitteachers[1], Convert.ToInt32(splitteachers[2]), splitteachers[3]);
                        this._teacherslist.Add(teacher);
                    }
                }

                counter = 1;
                foreach (Teacher eachteacher in this._teacherslist)
                {
                    teacherdisplay += string.Format("{0}/ {1}, Trigramme : {2}\n", counter, eachteacher.DisplayName(), eachteacher.Trigram);
                    counter++;
                }

                return(teacherdisplay + "\nChoisir un enseignant en donnant son trigramme pour afficher son salaire " +
                       "et tous ses eleves en fonction des ses activites ou taper B pour revenir au menu principal.");

            //Displays the list of activities
            case "3":

                _studentchosen  = false;
                _teacherchosen  = false;
                _activitychosen = true;

                string activitydisplay = "\nVoici la liste des activites\n";

                if (this._activitieslist.Count == 0)
                {
                    ReturnActivities result = new ReturnActivities(this._teacherslist);
                    this._activitieslist = result.List();
                }

                activitydisplay += "Nom du cours" + "\tCode du cours" + "\tNbre ECTS" + "\tEnseignant\n";

                foreach (Activity eachactivity in this._activitieslist)
                {
                    //More or less tab depending on the length of the name of the activity to align
                    if (eachactivity.Name.Length < 10)
                    {
                        activitydisplay += eachactivity.Name + "\t\t" + eachactivity.Code + "\t\t" + eachactivity.ECTS + "\t\t" + eachactivity.Teacher.Trigram + "\n";
                    }
                    else
                    {
                        activitydisplay += eachactivity.Name + "\t" + eachactivity.Code + "\t\t" + eachactivity.ECTS + "\t\t" + eachactivity.Teacher.Trigram + "\n";
                    }
                }

                return(activitydisplay + "\nChoisir une activite en donnant son code pour afficher le(s) livre(s) " +
                       "associe(s) ou taper B pour revenir au menu principal.");

            default:

                return("Veuillez entrer l'un des numeros de liste existants");
            }
        }