示例#1
0
        private static void AutoFillTrainers()
        {
            //currect directory
            string current = Directory.GetCurrentDirectory();

            //the path to the file with the trainers for auto import
            string path = Path.Combine(current, @"..\..\Dataa\autotrainers.txt");

            //read the lines of the file
            string[] allTrainers;
            try
            {
                allTrainers = File.ReadAllLines(path);
            }
            catch (FileNotFoundException)
            {
                Console.WriteLine("autotrainers.txt file not found");
                Console.WriteLine("this program searcher for an autotrainers.txt file in '..\\..\\Data' relative to the application\n");
                return;
            }
            catch (DirectoryNotFoundException)
            {
                Console.WriteLine("directory 'Data' not found");
                Console.WriteLine("this program searcher for an autotrainers.txt file in '..\\..\\Data' relative to the application\n");
                return;
            }

            //get the size of trainers list, we need for later
            int sizeBefore = SchoolManager.TrainerList.Count;

            //for every trainer
            foreach (string line in allTrainers)
            {
                //split the line and save the parts in an array
                string[] items = line.Split('-');

                //check if arguments are missing
                if (items.Length < 3)
                {
                    Console.WriteLine("arguments are missing\n");
                    continue;
                }
                else if (items.Length > 3)
                {
                    Console.WriteLine("too many arguments\n");
                    continue;
                }

                string fname   = items[0].Trim();
                string lname   = items[1].Trim();
                string subject = items[2].Trim();

                //check if trainer exists already
                if (TrainerExists(fname, lname))
                {
                    Console.WriteLine($"{fname} {lname} exists already\n");
                    continue;
                }

                //create a new trainer
                Trainer t = new Trainer()
                {
                    FirstName = fname,
                    LastName  = lname,
                    Subject   = subject
                };

                //add it to the list
                SchoolManager.TrainerList.Add(t);
            }
            //check if we added any trainers
            if (SchoolManager.TrainerList.Count == sizeBefore)
            {
                Console.WriteLine("Couldn't auto save any new trainers from the file");
            }
            else
            {
                Console.WriteLine($"Successfully saved {SchoolManager.TrainerList.Count - sizeBefore} new trainers");
            }
            Console.WriteLine();
        }
示例#2
0
        public static void SyntheticData()
        {
            DateTime date1 = new DateTime(2019, 6, 19);
            DateTime date2 = new DateTime(2019, 6, 18);
            DateTime date3 = new DateTime(2019, 6, 17);
            DateTime date4 = new DateTime(2019, 6, 21);

            //Courses
            Course c1 = new Course("CB1", "part time", "c#", date3, date4);
            Course c2 = new Course("CB2", "full time", "JAVA", date3, date4);
            Course c3 = new Course("CB3", "full time", "c#", date3, date4);
            Course c4 = new Course("CB4", "part time", "c#", date3, date4);

            List <Course> Courses = new List <Course>();

            Courses.Add(c1);
            Courses.Add(c2);
            Courses.Add(c3);
            Courses.Add(c4);

            //Students
            Student s1 = new Student("Mairi", "Ioannou", date4, 2500);
            Student s2 = new Student("Xristos", "Xristou", date2, 0);
            Student s3 = new Student("Gewrgios", "Gewrgioy", date3, 2200);
            Student s4 = new Student("Panos", "Panou", date2, 2250);

            List <Student> Students = new List <Student>();

            Students.Add(s1);
            Students.Add(s2);
            Students.Add(s3);
            Students.Add(s4);

            //Trainers
            Trainer t1 = new Trainer("Argirhs", "Pagidas", "python");
            Trainer t2 = new Trainer("Ektoras", "Gkatsos", "data base");
            Trainer t3 = new Trainer("Georgios", "Tzoras", "html");
            Trainer t4 = new Trainer("Giannhs", "Pappas", "sql");

            List <Trainer> Trainers = new List <Trainer>();

            Trainers.Add(t1);
            Trainers.Add(t2);
            Trainers.Add(t3);
            Trainers.Add(t4);

            //Assignmets
            Assignment a1 = new Assignment("project1", "part A", date1, 52, 36);
            Assignment a2 = new Assignment("project2", "part A", date2, 64, 22);
            Assignment a3 = new Assignment("project3", "part A", date3, 58, 24);
            Assignment a4 = new Assignment("project4", "part A", date4, 40, 40);

            List <Assignment> Assigments = new List <Assignment>();

            Assigments.Add(a1);
            Assigments.Add(a2);
            Assigments.Add(a3);
            Assigments.Add(a4);

            OutputCourse(Courses);
            OutputStudent(Students);
            OutputTrainer(Trainers);
            OutputAssignment(Assigments);

            //SpC

            List <Student> Students1 = new List <Student>();

            Students1.Add(s1);
            Students1.Add(s2);
            List <Student> Students2 = new List <Student>();

            Students2.Add(s3);
            Students2.Add(s4);

            SpC spc1 = new SpC();

            spc1.course     = c1;
            spc1.Studentspc = Students1;

            SpC spc2 = new SpC();

            spc2.course     = c2;
            spc2.Studentspc = Students2;

            List <SpC> SpC = new List <SpC>();

            AddToList(SpC, spc1);
            AddToList(SpC, spc2);
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("------STUDENTS   PER   COURSE-----------");
            foreach (var item in SpC)
            {
                item.OutputSpC();
            }

            //TpC

            List <Trainer> Trainers1 = new List <Trainer>();

            Trainers1.Add(t1);
            Trainers1.Add(t2);
            List <Trainer> Trainers2 = new List <Trainer>();

            Trainers2.Add(t3);
            Trainers2.Add(t4);

            TpC tpc1 = new TpC();

            tpc1.course     = c3;
            tpc1.Trainertpc = Trainers1;
            TpC tpc2 = new TpC();

            tpc2.course     = c4;
            tpc2.Trainertpc = Trainers2;

            List <TpC> TpC = new List <TpC>();

            AddToList(TpC, tpc1);
            AddToList(TpC, tpc2);
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("------TRAINERS   PER   COURSE-----------");
            foreach (var item in TpC)
            {
                item.OutputTpC();
            }

            //ApC

            List <Assignment> Assignmets1 = new List <Assignment>();

            Assignmets1.Add(a1);
            Assignmets1.Add(a2);
            List <Assignment> Assignmets2 = new List <Assignment>();

            Assignmets2.Add(a3);
            Assignmets2.Add(a4);

            ApC apc1 = new ApC();

            apc1.course       = c1;
            apc1.Assigmentapc = Assignmets1;
            ApC apc2 = new ApC();

            apc2.course       = c3;
            apc2.Assigmentapc = Assignmets2;

            List <ApC> ApC = new List <ApC>();

            AddToList(ApC, apc1);
            AddToList(ApC, apc2);
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("------ASSIGNMETS   PER   COURSE-----------");
            foreach (var item in ApC)
            {
                item.OutputApC();
            }

            //ApCpS


            List <Assignment> ass2 = new List <Assignment>();

            ass2.Add(a2);
            ass2.Add(a3);
            ApC apc4 = new ApC();          //1o

            apc4.course       = c4;
            apc4.Assigmentapc = ass2;

            ApC apc3 = new ApC();           //2o

            apc3.course       = c3;
            apc3.Assigmentapc = Assignmets1;

            ApCpS apcps1 = new ApCpS();

            apcps1.student = s1;
            apcps1.Assigmentapcps.Add(apc4);
            apcps1.Assigmentapcps.Add(apc3);

            ApCpS apcps2 = new ApCpS();

            apcps2.student = s3;
            apcps2.Assigmentapcps.Add(apc3);

            List <ApCpS> APCPC = new List <ApCpS>();

            APCPC.Add(apcps1);
            APCPC.Add(apcps2);

            Console.WriteLine("------ASSIGNMETS   PER   STUDENTS-----------");
            foreach (var item in APCPC)
            {
                item.OutputApCpS();
            }

            Console.WriteLine();
            Console.WriteLine("---------students in multiple courses-------");
            var list = StudentsBelongtoMul(APCPC);

            OutputStudent(list);

            Console.WriteLine("---------students with assignment this calendar week-------");
            Console.WriteLine(@"dokimase me 21/6 :)");
            var lista = StudentsSubSameWeek(APCPC);

            OutputStudent(lista);
        }