static void Main(string[] args)
        {
            Cohort cohort1 = new Cohort()
            {
                id   = 1,
                name = "Cohort 1",
            };
            Cohort cohort2 = new Cohort()
            {
                id   = 2,
                name = "Cohort 2"
            };
            Cohort cohort3 = new Cohort()
            {
                id   = 3,
                name = "Cohort 3"
            };

            Student sarah = new Student()
            {
                id          = 1,
                firstName   = "Sarah",
                lastName    = "Brooks",
                slackHandle = "@sarahBrooks",
                cohort      = cohort3
            };
            Student swathi = new Student()
            {
                id          = 2,
                firstName   = "Swathi",
                lastName    = "Mukkamala",
                slackHandle = "@swathiMukkamala",
                cohort      = cohort3
            };
            Student barry = new Student()
            {
                id          = 3,
                firstName   = "Barry",
                lastName    = "Griffith",
                slackHandle = "@barryGriffith",
                cohort      = cohort2
            };
            Student pat = new Student()
            {
                id          = 4,
                firstName   = "Pat",
                lastName    = "Shaver",
                slackHandle = "@patShaver",
                cohort      = cohort3
            };
            Student mandy = new Student()
            {
                id          = 5,
                firstName   = "Mandy",
                lastName    = "Campbell",
                slackHandle = "@mandyCampbell",
                cohort      = cohort2
            };

            Exercise studentExercises = new Exercise()
            {
                id       = 1,
                name     = "Student Exercise",
                language = "C#"
            };
            Exercise urbanPlanner = new Exercise()
            {
                id       = 2,
                name     = "Urban Planner",
                language = "C#"
            };
            Exercise kennel = new Exercise()
            {
                id       = 3,
                name     = "Kennel",
                language = "React"
            };
            Exercise dailyJournal = new Exercise()
            {
                id       = 4,
                name     = "Daily Journal",
                language = "JavaScript"
            };

            Instructor jordan = new Instructor()
            {
                id          = 1,
                firstName   = "Jordan",
                lastName    = "Castelloe",
                slackHandle = "@jordanCastelloe",
                specialty   = "Pop Culture References",
                cohort      = cohort1
            };
            Instructor tommy = new Instructor()
            {
                id          = 2,
                firstName   = "Tommy",
                lastName    = "Spurlock",
                slackHandle = "@tommySpurlock",
                specialty   = "Pep Talks",
                cohort      = cohort3
            };
            Instructor jacob = new Instructor()
            {
                id          = 3,
                firstName   = "Jacob",
                lastName    = "Perry",
                slackHandle = "@jacobPerry",
                specialty   = "Video Game Capstones",
                cohort      = cohort2
            };
        }
Exemple #2
0
        static void Main(string[] args)
        {
            //CREATE STUDENT OBJECTS
            Student Jordan = new Student("Jordan", "Rosas", "@JJROS", "C28");
            Student Nick   = new Student("Nick", "Hansen", "@NTHANSEN", "C29");
            Student Bubba  = new Student("Bubba", "Franks", "@BIGbubba", "C29");
            Student Hunter = new Student("Hunter", "Metts", "@HunterDaddy", "C30");
            Student Asia   = new Student("Asia", "Carter", "@AsianPersuasian", "C31");

            //CREATE INSTRUCTOR OBJECTS
            Instructor Jisie = new Instructor("Jisie", "David", "@boss", "C29");
            Instructor Steve = new Instructor("Steve", "McCodeycode", "@coach", "C30");
            Instructor Han   = new Instructor("Han", "Solo", "@nonationarmy", "C28");
            Instructor Rick  = new Instructor("Rick", "Roll", "@nevergiveyouup", "C31");


            //CREATE COHORT OBJECTS
            Cohort c28 = new Cohort("C28");
            Cohort c29 = new Cohort("C29");
            Cohort c30 = new Cohort("C30");
            Cohort c31 = new Cohort("C31");

            //CREATE INSTANCES FOR EACH STUDENT EXERCISE LISTS
            List <Exercise> nickExercises   = new List <Exercise>();
            List <Exercise> hunterExercises = new List <Exercise>();
            List <Exercise> asiaExercises   = new List <Exercise>();
            List <Exercise> jordanExercises = new List <Exercise>();

            //ADD EXERCISE OBJECTS
            Exercise loops   = new Exercise("loops", "JavaScript");
            Exercise headers = new Exercise("headers", "HTML");
            Exercise arrays  = new Exercise("arrays", "JavaScript");
            Exercise grids   = new Exercise("grids", "CSS");

            //USING THE .studentListIN THE COHORT OBJECT, CREATE STUDENT LISTS FOR EACH COHORT.
            c28.studentList = new List <Student>();
            c29.studentList = new List <Student>();
            c30.studentList = new List <Student>();
            c31.studentList = new List <Student>();

            //ADD STUDENTS TO THEIR RESPECTIVE COHORT LIST
            c28.studentList.Add(Jordan);

            c29.studentList.Add(Nick);
            c29.studentList.Add(Bubba);

            c30.studentList.Add(Hunter);

            c31.studentList.Add(Asia);

            //CREATE INSTANCES OF INSTRUCTOR LISTS
            List <Instructor> cohort28Instructors = new List <Instructor>();
            List <Instructor> cohort29Instructors = new List <Instructor>();
            List <Instructor> cohort30Instructors = new List <Instructor>();
            List <Instructor> cohort31Instructors = new List <Instructor>();

            //ADD INSTRUCTORS TO RESPECTIVE COHORT LIST
            cohort28Instructors.Add(Han);
            cohort29Instructors.Add(Jisie);
            cohort30Instructors.Add(Steve);
            cohort31Instructors.Add(Rick);

            //ADD STUDENT LIST AND TEACHER LIST TO COHORTS (is this necessary?)
            // c28.Add(cohort28Students);
            // c28.Add(cohort28Instructors);

            //METHOD CALL FOR AN INSTRUCTOR TO ASSIGN AN EXCERCISE TO AN ENTIRE COHORT OF STUDENTS
            // Jisie.asignExercise(loops, cohort29Students);
            //Han.asignExercise(arrays, c28);
            //Han.asignExercise(loops, c28);
            Jisie.asignExercise(arrays, c29);
            Jisie.asignExercise(grids, c29);
            Steve.asignExercise(grids, c30);
            Steve.asignExercise(headers, c30);
            Rick.asignExercise(arrays, c31);
            Rick.asignExercise(headers, c31);
            Rick.asignExercise(loops, c31);

            List <Student> students = new List <Student>()
            {
                Jordan,
                Nick,
                Bubba,
                Hunter,
                Asia
            };
            List <Exercise> exercises = new List <Exercise>()
            {
                loops,
                headers,
                arrays,
                grids
            };

            List <Instructor> instructors = new List <Instructor>()
            {
                Han,
                Jisie,
                Steve,
                Rick,
            };

            List <Cohort> cohorts = new List <Cohort>()
            {
                c28,
                c29,
                c30,
                c31
            };

            /*
             * List exercises for the JavaScript language by using the Where() LINQ method.
             */
            IEnumerable <Exercise> JSexercises = (from e in exercises
                                                  where e.exerciseLanguage == "JavaScript"
                                                  select e).ToList();

            foreach (Exercise e in JSexercises)
            {
                Console.WriteLine($"{e.exerciseName} is written in JS");
            }

            /*
             * List students in a particular cohort by using the Where() LINQ method.
             */

            IEnumerable <Student> c29Students = (from s in students
                                                 where s.cohort == "C29"
                                                 select s).ToList();

            foreach (Student s in c29Students)
            {
                Console.WriteLine($"{ s.firstName} { s.lastName} is in cohort 29 ");
            }

            /*
             * List instructors in a particular cohort by using the Where() LINQ method.
             */

            IEnumerable <Instructor> c29Instructor = (from i in instructors
                                                      where i.cohort == "C29"
                                                      select i).ToList();

            foreach (Instructor i in c29Instructor)
            {
                Console.WriteLine($"{i.firstName} is an instrutor for C29");
            }

            /*
             * Sort the students by their last name.
             */
            IEnumerable <Student> allStudents = (from a in students
                                                 orderby a.lastName descending
                                                 select a).ToList();

            Console.WriteLine("");
            Console.WriteLine("Students ordered by last name");
            foreach (Student a in allStudents)
            {
                Console.WriteLine($"{a.lastName}, {a.firstName}");
            }

            /*
             * Display any students that aren't working on any exercises (Make sure one of your student instances don't have any exercises. Create a new student if you need to.)
             */


            IEnumerable <Student> studentExercises = (from n in students
                                                      where n.exerciseList.Count() == 0
                                                      select n).ToList();

            foreach (Student n in studentExercises)
            {
                Console.WriteLine($"{n.firstName} has no exercises.");
            }


            /*
             * Which student is working on the most exercises? Make sure one of your students has more exercises than the others.
             */
            IEnumerable <Student> mostExercises = (from m in students
                                                   orderby m.exerciseList.Count descending
                                                   select m).ToList();
            var topStudent = mostExercises.First();
            {
                Console.WriteLine($"{topStudent.firstName} has the most exercises");
            }


            /*
             * How many students in each cohort?
             */
            IEnumerable <Student> studentByCohort = new List <Student>
            {
            };

            Console.ReadKey();
        }
Exemple #3
0
 static void AssignInstructorsToCohort(Instructor instr, Cohort co) => co.instructorCount.Add(instr);
Exemple #4
0
 static void AssignStudentsToCohort(Student stu, Cohort co) => co.studentCount.Add(stu);
Exemple #5
0
        static void Main(string[] args)
        {
            Exercise FirstExercise  = new Exercise("Kennel", "ReactJS");
            Exercise SecondExercise = new Exercise("Bangazon", "C#");
            Exercise ThirdExercise  = new Exercise("Welcome to Nashville", "JavaScript");
            Exercise FourthExercise = new Exercise("Superhero", "CSS");

            Student FirstStudent  = new Student("Asia", "Carter", "CaptainAsia123");
            Student SecondStudent = new Student("Jordan", "Rosas", "GifMasterFlex");
            Student ThirdStudent  = new Student("Joey", "Baumann", "CoderMan5");
            Student FourthStudent = new Student("Maggie", "Leavell", "EveningCoder8");

            Instructor FirstInstructor  = new Instructor("Joe", "Sheperd", "TheJoe");
            Instructor SecondInstructor = new Instructor("Andy", "Collins", "GlassesJacketShirtMan");
            Instructor ThirdInstructor  = new Instructor("Leah", "Hoefling", "MemeCommander");

            Cohort FirstCohort = new Cohort("Cohort 28");

            FirstInstructor.Cohort = FirstCohort;
            FirstCohort.Instructors.Add(FirstInstructor);

            Cohort SecondCohort = new Cohort("Cohort 29");

            SecondCohort.Students.Add(FirstStudent);
            SecondCohort.Students.Add(SecondStudent);
            SecondCohort.Students.Add(ThirdStudent);
            SecondInstructor.Cohort = SecondCohort;
            ThirdInstructor.Cohort  = SecondCohort;
            SecondCohort.Instructors.Add(SecondInstructor);
            SecondCohort.Instructors.Add(ThirdInstructor);

            Cohort ThirdCohort = new Cohort("Cohort E8");

            ThirdCohort.Students.Add(FourthStudent);
            ThirdCohort.Instructors.Add(ThirdInstructor);

            FirstStudent.Cohort  = SecondCohort;
            SecondStudent.Cohort = SecondCohort;
            ThirdStudent.Cohort  = SecondCohort;
            FourthStudent.Cohort = ThirdCohort;

            SecondInstructor.AssignExercise(FirstExercise, FirstStudent);
            SecondInstructor.AssignExercise(SecondExercise, FirstStudent);
            SecondInstructor.AssignExercise(FirstExercise, SecondStudent);
            SecondInstructor.AssignExercise(ThirdExercise, SecondStudent);
            SecondInstructor.AssignExercise(FirstExercise, ThirdStudent);
            SecondInstructor.AssignExercise(SecondExercise, ThirdStudent);
            SecondInstructor.AssignExercise(ThirdExercise, ThirdStudent);

            ThirdInstructor.AssignExercise(FirstExercise, FourthStudent);
            ThirdInstructor.AssignExercise(SecondExercise, FourthStudent);

            List <Student> students = new List <Student>()
            {
                FirstStudent,
                SecondStudent,
                ThirdStudent,
                FourthStudent
            };
            List <Exercise> exercises = new List <Exercise>()
            {
                FirstExercise,
                SecondExercise,
                ThirdExercise,
                FourthExercise
            };

            foreach (Student student in students)
            {
                List <string> studentExercises = new List <string>();
                foreach (Exercise studentExercise in student.Exercises)
                {
                    studentExercises.Add(studentExercise.Name);
                }
                Console.WriteLine($"{student.FirstName} {student.LastName} is working on: {String.Join(", ", studentExercises)}");
            }

            List <Instructor> instructors = new List <Instructor>()
            {
                FirstInstructor,
                SecondInstructor,
                ThirdInstructor
            };

            List <Cohort> cohorts = new List <Cohort>()
            {
                FirstCohort,
                SecondCohort,
                ThirdCohort,
            };

            Console.WriteLine("-----");
            List <Exercise> javascriptExercises = exercises.Where(e => e.Language == "JavaScript").ToList();

            foreach (Exercise e in javascriptExercises)
            {
                Console.WriteLine($"{e.Name} is a JavaScript exercise");
            }
            Console.WriteLine("-----");
            List <Student> students29 = students.Where(s => s.Cohort.Name == "Cohort 29").ToList();

            foreach (Student s in students29)
            {
                Console.WriteLine($"{s.FirstName} {s.LastName} is in Cohort 29");
            }
            Console.WriteLine("-----");
            List <Instructor> instructors29 = instructors.Where(i => i.Cohort.Name == "Cohort 29").ToList();

            foreach (Instructor i in instructors29)
            {
                Console.WriteLine($"{i.FirstName} {i.LastName} is an instructor in Cohort 29");
            }
            Console.WriteLine("-----");
            List <Student> sortedStudents = students.OrderBy(s => s.LastName).ToList();

            foreach (Student s in sortedStudents)
            {
                Console.WriteLine($"{s.FirstName} {s.LastName}");
            }
            Student FifthStudent = new Student("Cole", "Bryant", "colebryant");

            FifthStudent.Cohort = SecondCohort;
            students.Add(FifthStudent);
            List <Student> unassignedStudents = students.Where(s => s.Exercises.Count() == 0).ToList();

            Console.WriteLine("-----");
            foreach (Student s in unassignedStudents)
            {
                Console.WriteLine($"{s.FirstName} {s.LastName} was not assigned any assignments");
            }
            Console.WriteLine("-----");
            Student mostAssigned = students.OrderByDescending(s => s.Exercises.Count()).First();

            Console.WriteLine($"{mostAssigned.FirstName} {mostAssigned.LastName} was assigned the most exercises");
            Console.WriteLine("-----");
            List <string> cohortNumbers = cohorts.Select(c => $"There are currently {c.Students.Count()} student(s) in {c.Name}").ToList();

            foreach (string x in cohortNumbers)
            {
                Console.WriteLine(x);
            }
        }
Exemple #6
0
        static void Main()
        {
            // 1. Create 4 exercises
            // Need to add exercises so they can be assigned to students.
            Exercise exercise_1 = new Exercise(1, "chess", "HTML");
            Exercise exercise_2 = new Exercise(2, "go", "JS");
            Exercise exercise_3 = new Exercise(3, "risk", "SQL");
            Exercise exercise_4 = new Exercise(4, "monopoly", "JS");
            Exercise exercise_5 = new Exercise(5, "gin rummy", "SQL");
            Exercise exercise_6 = new Exercise(6, "global thermonuclear war", "C Sharp");

            Console.WriteLine();                // Blank line

            // 2. Create 3 cohorts
            // Built the cohorts with the constructor in Cohort.cs.
            Cohort C29 = new Cohort(29, "Cohort 29");
            Cohort C30 = new Cohort(30, "Cohort 30");
            Cohort C31 = new Cohort(31, "Cohort 31");

            Console.WriteLine(C29.name);
            Console.WriteLine(C29.id.ToString());
            Console.WriteLine();                // Blank line
            Console.WriteLine(C30.name);
            Console.WriteLine(C30.id.ToString());
            Console.WriteLine();                // Blank line
            Console.WriteLine(C31.name);
            Console.WriteLine(C31.id.ToString());

            // Create 4 students and assign them to one of the cohorts
            // Now use the new constructor for the other students
            Student Gabs     = new Student(2, 29, "Gabs", "Crawford", "cheer_1");
            Student Tay      = new Student(2, 29, "Taylor", "Rausch", "cheer_love");
            Student Caroline = new Student(2, 30, "Caroline", "Reynolds", "flyer1");
            Student Olivia   = new Student(2, 31, "Olivia", "Meyers", "sup_dog");

            // Create 3 instructors and assign them to one of the cohorts.
            Instructor instructor_1 = new Instructor(1, 29, "Jisie", "David", "jdavid");
            Instructor instructor_2 = new Instructor(2, 30, "Andy", "Collins", "acollins");
            Instructor instructor_3 = new Instructor(3, 31, "Leah", "Gwin", "lgwin");

            // Assign instructors to cohorts
            AssignInstructorsToCohort(instructor_1, C29);
            AssignInstructorsToCohort(instructor_2, C30);
            AssignInstructorsToCohort(instructor_3, C31);

            // Assign students to cohort
            AssignStudentsToCohort(Gabs, C29);
            AssignStudentsToCohort(Tay, C29);
            AssignStudentsToCohort(Caroline, C30);
            AssignStudentsToCohort(Olivia, C31);

            // Instructors assign students to exercises

            // Jisie assigns exercises 1 and 2 for all students
            instructor_1.assignExercises(Gabs, exercise_1);
            instructor_1.assignExercises(Gabs, exercise_2);
            instructor_1.assignExercises(Tay, exercise_1);
            instructor_1.assignExercises(Tay, exercise_2);
            instructor_1.assignExercises(Caroline, exercise_1);
            instructor_1.assignExercises(Caroline, exercise_2);
            instructor_1.assignExercises(Olivia, exercise_1);
            instructor_1.assignExercises(Olivia, exercise_2);

            // Andy assigns exercises 3 and 4 for all students
            instructor_2.assignExercises(Gabs, exercise_3);
            instructor_2.assignExercises(Gabs, exercise_4);
            instructor_2.assignExercises(Tay, exercise_3);
            instructor_2.assignExercises(Tay, exercise_4);
            instructor_2.assignExercises(Caroline, exercise_3);
            instructor_2.assignExercises(Caroline, exercise_4);
            instructor_2.assignExercises(Olivia, exercise_3);
            instructor_2.assignExercises(Olivia, exercise_4);

            // Andy assigns exercises 5 and 6 for all students
            instructor_2.assignExercises(Gabs, exercise_5);
            instructor_2.assignExercises(Gabs, exercise_6);
            instructor_2.assignExercises(Tay, exercise_5);
            instructor_2.assignExercises(Tay, exercise_6);
            instructor_2.assignExercises(Caroline, exercise_5);
            instructor_2.assignExercises(Caroline, exercise_6);
            instructor_2.assignExercises(Olivia, exercise_5);
            instructor_2.assignExercises(Olivia, exercise_6);
        }
Exemple #7
0
        static void Main(string[] args)
        {
            //  Create 4, or more, exercises.
            Exercise lesson1_P = new Exercise("Intro to Python", "Python");
            Exercise lesson2_P = new Exercise("Intermediate Python", "Python");
            Exercise lesson3_P = new Exercise("Advanced Python", "Python");

            Exercise lesson1_C = new Exercise("Intro to C#", "C#");
            Exercise lesson2_C = new Exercise("Intermediate C#", "C#");
            Exercise lesson3_C = new Exercise("Advanced C#", "C#");

            Exercise lesson1_R = new Exercise("Intro to Ruby", "Ruby");
            Exercise lesson2_R = new Exercise("Intermediate Ruby", "Ruby");
            Exercise lesson3_R = new Exercise("Advanced Ruby", "Ruby");
            // Create 3, or more, cohorts.
            Cohort cohort_1 = new Cohort("Cohort_1");
            Cohort cohort_2 = new Cohort("Cohort_2");
            Cohort cohort_3 = new Cohort("Cohort_3");
            // Create 4, or more, students and assign them to one of the cohorts.
            Student student_1 = new Student("Jackie", "Robinson", "JRob", 1);
            Student student_2 = new Student("Bo", "Jackson", "BJack", 2);
            Student student_3 = new Student("Sammy", "Sosa", "SammySosa", 3);
            // Create 3, or more, instructors and...
            Instructor instructor_1 = new Instructor("Brenda", "Long", "BrendaLong", 1, "Javascript");
            Instructor instructor_2 = new Instructor("Adam", "Schaeffer", "AdamRulez", 2, "C#");
            Instructor instructor_3 = new Instructor("Bryan", "Nilsen", "ByanFknNilsen", 3, "Python");

            // ...assign them to one of the cohorts.
            cohort_1.AddToInstructors(instructor_1);
            cohort_2.AddToInstructors(instructor_2);
            cohort_3.AddToInstructors(instructor_3);
            // Have each instructor assign 2 exercises to each of the students.
            instructor_1.addAssignment(student_1, lesson1_C);
            instructor_1.addAssignment(student_1, lesson2_C);
            instructor_1.addAssignment(student_2, lesson1_C);
            instructor_1.addAssignment(student_2, lesson2_C);
            instructor_1.addAssignment(student_3, lesson1_C);
            instructor_1.addAssignment(student_3, lesson2_C);

            instructor_2.addAssignment(student_1, lesson1_P);
            instructor_2.addAssignment(student_1, lesson2_P);
            instructor_2.addAssignment(student_2, lesson1_P);
            instructor_2.addAssignment(student_2, lesson2_P);
            instructor_2.addAssignment(student_3, lesson1_P);
            instructor_2.addAssignment(student_3, lesson2_P);

            instructor_3.addAssignment(student_1, lesson1_R);
            instructor_3.addAssignment(student_1, lesson2_R);
            instructor_3.addAssignment(student_2, lesson1_R);
            instructor_3.addAssignment(student_2, lesson2_R);
            instructor_3.addAssignment(student_3, lesson1_R);
            instructor_3.addAssignment(student_3, lesson2_R);

            // Create a list of students.Add all of the student instances to it.
            List <Student> student_list = new List <Student>();

            student_list.Add(student_1);
            student_list.Add(student_2);
            student_list.Add(student_3);
            // Create a list of exercises.Add all of the exercise instances to it.
            List <Exercise> exercise_list = new List <Exercise>();

            exercise_list.Add(lesson1_C);
            exercise_list.Add(lesson2_C);
            exercise_list.Add(lesson3_C);
            exercise_list.Add(lesson1_P);
            exercise_list.Add(lesson2_P);
            exercise_list.Add(lesson3_P);
            exercise_list.Add(lesson1_R);
            exercise_list.Add(lesson2_R);
            exercise_list.Add(lesson3_R);
        }
 //Assign a student to a cort
 static void AssignStudentCohort(Student student, Cohort cohort) => cohort.StudentList.Add(student);
        static void Main(string[] args)
        {
            /////////////////////////////////Exercies
            Exercise dogs = new Exercise();

            dogs.Name     = "dogs";
            dogs.Language = "bark";

            Exercise cats = new Exercise();

            cats.Name     = "cats";
            cats.Language = "meow";

            Exercise fish = new Exercise();

            fish.Name     = "fish";
            fish.Language = "bloop";

            Exercise hamster = new Exercise();

            hamster.Name     = "hamster";
            hamster.Language = "meep";

            ///////////////////////Cohorts, list student and instructor
            Cohort C29 = new Cohort();

            C29.Name = "C29";

            Cohort C30 = new Cohort();

            C30.Name = "C30";

            Cohort C31 = new Cohort();

            C31.Name = "C31 aka the cool kids, also known as the cool kids club";

            //////////////////////////////Students, add exercise list
            Student Bill = new Student();

            Bill.FirstName   = "Bill";
            Bill.LastName    = "Bob";
            Bill.SlackHandle = "BillBob";
            Bill.Cohort      = C31;

            Student Steve = new Student();

            Steve.FirstName   = "Steve";
            Steve.LastName    = "Stevie";
            Steve.SlackHandle = "SteveStevie";
            Steve.Cohort      = C29;

            Student Bo = new Student();

            Bo.FirstName   = "Bo";
            Bo.LastName    = "Body";
            Bo.SlackHandle = "BoBody";
            Bo.Cohort      = C30;

            Student Blue = new Student();

            Blue.FirstName   = "Blue";
            Blue.LastName    = "Yellow";
            Blue.SlackHandle = "BlueYellow";
            Blue.Cohort      = C31;

            ///////////Instructors
            Instructor JDog = new Instructor();

            JDog.FirstName   = "Jisie";
            JDog.LastName    = "IDK";
            JDog.SlackHandle = "JDog";
            JDog.Cohort      = C31;
            JDog.Specialty   = "making bird noises";
            JDog.Assign(Bill, dogs, cats);
            JDog.Assign(Steve, dogs, cats);
            JDog.Assign(Bo, dogs, cats);
            JDog.Assign(Blue, dogs, cats);

            Instructor KMoney = new Instructor();

            KMoney.FirstName   = "Kristen";
            KMoney.LastName    = "IDK";
            KMoney.SlackHandle = "KMoney";
            KMoney.Cohort      = C31;
            KMoney.Specialty   = "making cupcakes";
            KMoney.Assign(Bill, dogs, cats);
            KMoney.Assign(Steve, dogs, cats);
            KMoney.Assign(Bo, dogs, cats);
            KMoney.Assign(Blue, dogs, cats);

            Instructor SteveNation = new Instructor();

            SteveNation.FirstName   = "Steve";
            SteveNation.LastName    = "Brownlee";
            SteveNation.SlackHandle = "SteveNation";
            SteveNation.Cohort      = C30;
            SteveNation.Specialty   = "making cupcakes";
            SteveNation.Assign(Bill, dogs, cats);
            SteveNation.Assign(Steve, dogs, cats);
            SteveNation.Assign(Bo, dogs, cats);
            SteveNation.Assign(Blue, dogs, cats);

            Instructor ATown = new Instructor();

            ATown.FirstName   = "Andy";
            ATown.LastName    = "Collins";
            ATown.SlackHandle = "ATown";
            ATown.Cohort      = C31;
            ATown.Specialty   = "making jokes";
            ATown.Assign(Bill, dogs, cats);
            ATown.Assign(Steve, dogs, cats);
            ATown.Assign(Bo, dogs, cats);
            ATown.Assign(Blue, fish, cats);

            ///////////////Lists
            List <Student> students = new List <Student> ()
            {
                Bill, Steve, Bo, Blue
            };

            List <Exercise> exerciseList = new List <Exercise> ()
            {
                dogs, cats, fish, hamster
            };

            foreach (Student stu in students)
            {
                Console.WriteLine($"{stu.FirstName} has to do these exercises: ");
                foreach (Exercise con in stu.Exercises)
                {
                    Console.WriteLine(con.Name);
                }
            }
        }
        static void Main(string[] args)
        {
            // Create exercises and add to list-----------------------------------
            var             exercise1 = new Exercise("C# Starter Project", "C#");
            var             exercise2 = new Exercise("React Nutshell", "Javascript");
            var             exercise3 = new Exercise("English Idioms", "C#");
            var             exercise4 = new Exercise("Urban Planner", "C#");
            var             exercise5 = new Exercise("Itinerary Builder", "Javascript");
            var             exercise6 = new Exercise("JS Nutshell", "Javascript");
            List <Exercise> exercises = new List <Exercise>()
            {
                exercise1, exercise2, exercise3, exercise4, exercise5, exercise6
            };

            // Creates all cohorts------------------------------------------------
            var           cohort1 = new Cohort("Day Classes - Cohort 32");
            var           cohort2 = new Cohort("Day Classes - Cohort 33");
            var           cohort3 = new Cohort("Day Classes - Cohort 34");
            var           cohort4 = new Cohort("Night Classes - Cohort 16");
            List <Cohort> cohorts = new List <Cohort>()
            {
                cohort1, cohort2, cohort3, cohort4
            };

            // Creates students and adds them to the list--------------------------
            var            student1 = new Student("Addam", "Joor", "addam.joor", cohort1);
            var            student2 = new Student("Emily", "Loggins", "emily.loggins", cohort1);
            var            student3 = new Student("Ellie", "Ash", "ellie.ash", cohort3);
            var            student4 = new Student("Ben", "Parker", "ben.parker", cohort2);
            var            student5 = new Student("Shelley", "Arnold", "shelley.arnold", cohort1);
            List <Student> students = new List <Student>()
            {
                student1, student2, student3, student4, student5
            };

            cohort1.CohortStudents.Add(student1);
            cohort1.CohortStudents.Add(student2);
            cohort1.CohortStudents.Add(student5);
            cohort3.CohortStudents.Add(student3);
            cohort2.CohortStudents.Add(student4);

            // Creates all instructors--------------------------------------------
            var instructor1 = new Instructor("Dance", "Storm", "dan.storm", cohort1, "Dancesplosion");
            var instructor2 = new Instructor("Bryan", "Nielson", "bryanfuckingnielson", cohort1, "High Five Hurricane");
            var instructor3 = new Instructor("Brenda", "Long", "brenda.long", cohort3, "Positivity Overload");
            var instructor4 = new Instructor("Adam", "Sheaffer", "adam.sheaffer", cohort2, "Hat Heard Round the World");

            foreach (Student student in students)
            {
                Console.WriteLine($"{student.FirstName} {student.LastName}");
            }
            ;

            System.Console.WriteLine();
            foreach (Exercise exercise in exercises)
            {
                Console.WriteLine($"Assignment: {exercise.ExerciseName} in {exercise.ExerciseLanguage}");
            }
            ;

            // Instructor assigns student with a specified exercise
            System.Console.WriteLine();
            instructor4.Assign(student1, exercise2);
            instructor2.Assign(student1, exercise3);
            instructor3.Assign(student2, exercise1);
            instructor1.Assign(student3, exercise4);
            instructor4.Assign(student4, exercise2);
            System.Console.WriteLine();

            // Consoles the student name followed by their respective list of assignments
            foreach (var student in students)
            {
                System.Console.WriteLine($"{student.FirstName}'s Assignment List:");
                foreach (var exercise in student.StudentExercises)
                {
                    System.Console.WriteLine($"{exercise.ExerciseName}");
                }
                System.Console.WriteLine();
            }

            // Select all exercises that utilize Javascript language
            var javaExercises = from exercise in exercises
                                where exercise.ExerciseLanguage == "Javascript"
                                select exercise;

            System.Console.WriteLine("All Javascript exercises:");
            foreach (Exercise exercise in javaExercises)
            {
                System.Console.WriteLine(exercise.ExerciseName);
            }

            // Select all students that are in cohort 32
            System.Console.WriteLine();
            var studentsOfCohort32 = from student in students
                                     where student.Cohort == cohort1
                                     select student;

            System.Console.WriteLine("All Students in Cohort 32:");
            foreach (Student student in studentsOfCohort32)
            {
                System.Console.WriteLine($"{student.FirstName} {student.LastName}");
            }

            // Order all students by last name
            System.Console.WriteLine();
            var sortedStudents = from student in students
                                 orderby student.LastName
                                 select student;

            System.Console.WriteLine("All students ordered by last name:");
            foreach (Student student in sortedStudents)
            {
                System.Console.WriteLine($"{student.FirstName} {student.LastName}");
            }

            // Sort students with no exercises assigned
            System.Console.WriteLine();
            var noExercises = from student in students
                              where student.StudentExercises.Count == 0
                              select student;

            System.Console.WriteLine("Students with no exercises assigned:");
            foreach (Student student in noExercises)
            {
                System.Console.WriteLine($"{student.FirstName} {student.LastName}");
            }

            // Find student with the most exercises assigned
            System.Console.WriteLine();
            var mostExercises = from student in students
                                orderby student.StudentExercises.Count descending
                                select student;

            System.Console.WriteLine("Student with most exercises:");
            foreach (Student student in mostExercises)
            {
                System.Console.WriteLine($"{student.FirstName} {student.LastName} - {student.StudentExercises.Count}");
            }
            ;

            // How many students per cohort?
            System.Console.WriteLine();
            var studentCount = from cohort in cohorts
                               orderby cohort.CohortStudents.Count descending
                               select cohort;

            System.Console.WriteLine("Number of students per cohort:");
            foreach (Cohort cohort in studentCount)
            {
                System.Console.WriteLine($"{cohort.CohortName} - {cohort.CohortStudents.Count}");
            }
            ;
        }
Exemple #11
0
        static void Main(string[] args)
        {
            Exercise dailyJournal = new Exercise("Daily Journal")
            {
                Langauge = "JavaScript"
            };
            Exercise nutshell = new Exercise("Nutshell")
            {
                Langauge = "JavaScript"
            };
            Exercise personalWebsite = new Exercise("Personal Website")
            {
                Langauge = "JavaScript"
            };
            Exercise calculator = new Exercise("Calculator")
            {
                Langauge = "JavaScript"
            };

            Cohort cohortOne   = new Cohort("Cohort One");
            Cohort cohortTwo   = new Cohort("Cohort Two");
            Cohort cohortThree = new Cohort("Cohort Three");

            Student austin = new Student("Austin", "Preece", "@RestInPreece")
            {
                Cohort = cohortThree
            };

            cohortThree.StudentList.Add(austin);

            Student sarah = new Student("Sarah", "Brooks", "@BookBurner")
            {
                Cohort = cohortThree
            };

            cohortThree.StudentList.Add(sarah);

            Student derekM = new Student("Derek", "Mayse", "@GordGuy666")
            {
                Cohort = cohortThree
            };

            cohortThree.StudentList.Add(derekM);

            Student devin = new Student("Devin", "Conroy", "@Tall&Handsome")
            {
                Cohort = cohortThree
            };

            cohortThree.StudentList.Add(devin);

            Student sydney = new Student("Sydney", "Wait", "@TrailRunner")
            {
                Cohort = cohortOne
            };


            cohortOne.StudentList.Add(sydney);

            Student jen = new Student("Jen", "Johnson", "@TeachersAide")
            {
                Cohort = cohortTwo
            };

            cohortTwo.StudentList.Add(jen);


            Instructor jordan = new Instructor("Jordan", "Castelloe")
            {
                Specialty = "Explaining things",
                Cohort    = cohortOne
            };
            Instructor tommy = new Instructor("Tommy", "Spurlock")
            {
                Specialty = "Motivating the class",
                Cohort    = cohortTwo
            };
            Instructor jacob = new Instructor("Jacob", "Perry")
            {
                Specialty = "Giving presentations",
                Cohort    = cohortThree
            };

            jordan.AssignExerciseToStudent(austin, dailyJournal);
            jordan.AssignExerciseToStudent(sarah, dailyJournal);
            jordan.AssignExerciseToStudent(sarah, nutshell);
            tommy.AssignExerciseToStudent(derekM, nutshell);
            tommy.AssignExerciseToStudent(devin, nutshell);
            jacob.AssignExerciseToStudent(sarah, calculator);
            jacob.AssignExerciseToStudent(devin, personalWebsite);

            List <Student> students = new List <Student>()
            {
                austin,
                sarah,
                derekM,
                devin,
                sydney,
                jen
            };

            List <Exercise> exercises = new List <Exercise>()
            {
                dailyJournal,
                nutshell,
                calculator,
                personalWebsite
            };

            List <Instructor> instructors = new List <Instructor>()
            {
                jordan,
                tommy,
                jacob
            };

            List <Cohort> cohorts = new List <Cohort>()
            {
                cohortOne,
                cohortTwo,
                cohortThree
            };


            exercises.Where(exercise => exercise.Langauge == "JavaScript").ToList().ForEach(exercise => Console.WriteLine(exercise.Name));
            Console.WriteLine();
            students.Where(student => student.Cohort == cohortOne).ToList().ForEach(student => Console.WriteLine($"{student.FirstName} {student.LastName}"));
            Console.WriteLine();
            instructors.Where(instructor => instructor.Cohort == cohortOne).ToList().ForEach(instructor => Console.WriteLine(instructor.FirstName));
            Console.WriteLine();
            students.OrderBy(student => student.LastName).ToList().ForEach(student => Console.WriteLine(student.LastName));
            Console.WriteLine();
            students.Where(student => student.AssignedExercises.Count() == 0).ToList().ForEach(student => Console.WriteLine(student.FirstName));
            Console.WriteLine();

            Console.WriteLine(students.Where(student => student.AssignedExercises.Count() == students.Max(student => student.AssignedExercises.Count())).ToList()[0].FirstName);

            cohorts.ForEach(cohort => Console.WriteLine(cohort.StudentList.Count()));
        }
        static void Main(string[] args)
        {
            var chickenMonkey = new Exercise("ChickenMonkey", "JS");
            var employees     = new Exercise("Company Employees", "C#");
            var stocks        = new Exercise("Stock Exchange", "C#");
            var dailyJournal  = new Exercise("Daily Journal", "React");

            var cohort32 = new Cohort("Cohort 32");
            var cohort28 = new Cohort("Cohort 28");
            var cohort34 = new Cohort("Cohort 34");

            var deep   = new Student("Deep", "Patel", "DP", cohort32);
            var joey   = new Student("Joey", "Driscoll", "JD", cohort32);
            var jason  = new Student("Jason", "Collum", "JC", cohort28);
            var collin = new Student("Collin", "Sandlin", "CS", cohort28);
            var dan    = new Student("Dan", "Storm", "DS", cohort34);
            var sean   = new Student("Sean", "Glavin", "SG", cohort34);

            var adam = new Instructor()
            {
                FirstName   = "Adam",
                LastName    = "Sheaffer",
                SlackHandle = "ADM",
                CohortName  = cohort32,
                Specialty   = "Type Script"
            };

            var bryan = new Instructor()
            {
                FirstName   = "Bryan",
                LastName    = "Neilson",
                SlackHandle = "BRYN",
                CohortName  = cohort34,
                Specialty   = "High Fives"
            };

            var steve = new Instructor()
            {
                FirstName   = "Steve",
                LastName    = "Brownlee",
                SlackHandle = "STV",
                CohortName  = cohort28,
                Specialty   = "Coach"
            };

            adam.AddExercise(deep, employees);
            adam.AddExercise(deep, stocks);
            bryan.AddExercise(deep, chickenMonkey);
            bryan.AddExercise(deep, dailyJournal);
            steve.AddExercise(deep, employees);
            steve.AddExercise(deep, stocks);

            adam.AddExercise(joey, employees);
            adam.AddExercise(joey, stocks);
            bryan.AddExercise(joey, chickenMonkey);
            bryan.AddExercise(joey, dailyJournal);
            steve.AddExercise(joey, employees);
            steve.AddExercise(joey, stocks);

            adam.AddExercise(jason, employees);
            adam.AddExercise(jason, stocks);
            bryan.AddExercise(jason, chickenMonkey);
            bryan.AddExercise(jason, dailyJournal);
            steve.AddExercise(jason, employees);
            steve.AddExercise(jason, stocks);

            adam.AddExercise(collin, employees);
            adam.AddExercise(collin, stocks);
            bryan.AddExercise(collin, chickenMonkey);
            bryan.AddExercise(collin, dailyJournal);
            steve.AddExercise(collin, employees);
            steve.AddExercise(collin, stocks);

            adam.AddExercise(dan, employees);
            adam.AddExercise(dan, stocks);
            bryan.AddExercise(dan, chickenMonkey);
            bryan.AddExercise(dan, dailyJournal);
            steve.AddExercise(dan, employees);
            steve.AddExercise(dan, stocks);

            adam.AddExercise(sean, employees);
            adam.AddExercise(sean, stocks);
            bryan.AddExercise(sean, chickenMonkey);
            bryan.AddExercise(sean, dailyJournal);
            steve.AddExercise(sean, employees);
            steve.AddExercise(sean, stocks);

            var students  = new List <Student>();
            var exercises = new List <Exercise>();

            students.Add(deep);
            students.Add(joey);
            students.Add(jason);
            students.Add(collin);
            students.Add(dan);
            students.Add(sean);

            exercises.Add(chickenMonkey);
            exercises.Add(employees);
            exercises.Add(stocks);
            exercises.Add(dailyJournal);

            // foreach (Student student in students)
            // {
            //     Console.WriteLine($"{student.FirstName} {student.LastName} is working on:");
            //     student.ShowExercises();
            //     Console.WriteLine("");
            // }

            foreach (Exercise exercise in exercises)
            {
                Console.WriteLine($"These students are working on {exercise.Name}:");

                foreach (Student student in students)
                {
                    if (student.Exercises.Contains(exercise))
                    {
                        Console.WriteLine($"{student.FirstName}");
                    }
                }
                Console.WriteLine("");
            }
        }
        static void Main(string[] args)
        {
            Exercise classes = new Exercise();

            classes.id             = 1;
            classes.nameOfExercise = "Classes in C#";
            classes.language       = "C#";

            Exercise lists = new Exercise();

            lists.id             = 2;
            lists.nameOfExercise = "Lists in C#";
            lists.language       = "C#";

            Exercise dailyJournal = new Exercise();

            dailyJournal.id             = 3;
            dailyJournal.nameOfExercise = "Daily Journal";
            dailyJournal.language       = "Javascript";

            Exercise watched = new Exercise();

            watched.id             = 4;
            watched.nameOfExercise = "Watched";
            watched.language       = "React";

            Cohort cohortOne = new Cohort();

            cohortOne.id         = 1;
            cohortOne.cohortName = "Cohort One";

            Cohort cohortTwo = new Cohort();

            cohortTwo.id         = 2;
            cohortTwo.cohortName = "Cohort Two";

            Cohort cohortThree = new Cohort();

            cohortThree.id         = 3;
            cohortThree.cohortName = "Cohort Three";

            Student alex = new Student()
            {
                id          = 1,
                firstName   = "Alex",
                lastName    = "Franklin",
                slackHandle = "Alex Franklin",
                Cohort      = cohortTwo,
                // cohortTwo.studentsInCohortList.Add(alex);
            };

            Student sable = new Student();

            sable.id          = 2;
            sable.firstName   = "Sable";
            sable.lastName    = "SAAAAAAAABLE";
            sable.slackHandle = "Sabs";
            sable.Cohort      = cohortOne;
            // cohortOne.studentsInCohortList.Add(sable);

            Student tommy = new Student();

            tommy.id          = 3;
            tommy.firstName   = "Tommy";
            tommy.lastName    = "Ymmot";
            tommy.slackHandle = "TomTom";
            tommy.Cohort      = cohortOne;
            // cohortOne.studentsInCohortList.Add(tommy);

            Student frank = new Student();

            frank.id          = 4;
            frank.firstName   = "Frank";
            frank.lastName    = "Knarf";
            frank.slackHandle = "FrankenFrank";
            frank.Cohort      = cohortThree;
            // cohortThree.studentsInCohortList.Add(frank);

            Student steve = new Student()
            {
                firstName   = "Steve",
                lastName    = "evetS",
                slackHandle = "Stevers",
                Cohort      = cohortThree,
            };


            cohortTwo.studentsInCohortList.Add(alex);
            cohortOne.studentsInCohortList.Add(sable);
            cohortOne.studentsInCohortList.Add(tommy);
            cohortThree.studentsInCohortList.Add(frank);

            Instructor jordan = new Instructor();

            jordan.id          = 1;
            jordan.firstName   = "Jordan";
            jordan.lastName    = "Nadroj";
            jordan.Cohort      = cohortOne;
            jordan.slackHandle = "Jordan";
            jordan.specialty   = "Wizardry";
            // cohortOne.instructorsInCohortList.Add(jordan);
            jordan.AddExercise(watched, sable);
            jordan.AddExercise(lists, tommy);



            Instructor instructorTommy = new Instructor();

            instructorTommy.id          = 2;
            instructorTommy.firstName   = "Tommy";
            instructorTommy.lastName    = "Ymmot";
            instructorTommy.Cohort      = cohortTwo;
            instructorTommy.slackHandle = "Tommmmmmmy";
            instructorTommy.specialty   = "Specialized in Charisma";
            // cohortTwo.instructorsInCohortList.Add(instructorTommy);
            instructorTommy.AddExercise(watched, alex);
            instructorTommy.AddExercise(lists, alex);


            Instructor josh = new Instructor();

            josh.id          = 1;
            josh.firstName   = "Josh";
            josh.lastName    = "Hsoj";
            josh.Cohort      = cohortThree;
            josh.slackHandle = "Joshington";
            josh.specialty   = "Beard";
            // cohortThree.instructorsInCohortList.Add(josh);
            josh.AddExercise(classes, frank);
            josh.AddExercise(dailyJournal, frank);
            josh.AddExercise(lists, frank);
            josh.AddExercise(watched, frank);


            cohortOne.instructorsInCohortList.Add(jordan);
            cohortTwo.instructorsInCohortList.Add(instructorTommy);
            cohortThree.instructorsInCohortList.Add(josh);

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

            students.Add(alex);
            students.Add(sable);
            students.Add(frank);
            students.Add(tommy);
            students.Add(steve);

            List <Exercise> exercises = new List <Exercise>();

            exercises.Add(classes);
            exercises.Add(lists);
            exercises.Add(watched);
            exercises.Add(dailyJournal);

            List <Instructor> instructors = new List <Instructor>()
            {
                instructorTommy, jordan, josh
            };

            List <Cohort> cohorts = new List <Cohort>()
            {
                cohortOne, cohortTwo, cohortThree
            };

            // List exercises for the JavaScript language by using the Where() LINQ method.

            IEnumerable <Exercise> JavascriptExercises = exercises.Where(exercises => exercises.language == "Javascript");

            // List students in a particular cohort by using the Where() LINQ method.

            IEnumerable <Student> studentsInCohortOne = students.Where(student => student.Cohort == cohortOne);

            // foreach (Student student in studentsInCohortOne)
            // {
            //     Console.WriteLine(student.firstName);
            // }

            // List instructors in a particular cohort by using the Where() LINQ method.

            IEnumerable <Instructor> instructorsInCohortOne = instructors.Where(instructor => instructor.Cohort == cohortOne);

            // foreach (Instructor instructor in instructorsInCohortOne)
            // {
            //     Console.WriteLine(instructor.firstName);
            // }

            // Sort the students by their last name.

            IEnumerable <Student> studentsSorted = students.OrderBy(student => student.lastName).ToList();


            // foreach (Student student in studentsSorted)
            // {
            //     Console.WriteLine(student.lastName);
            // }

            // Display any students that aren't working on any exercises (Make sure one of your student instances don't have any exercises. Create a new student if you need to.)

            IEnumerable <Student> lazyBois = students.Where(student => student.currentExercises.Count == 0);

            // foreach (Student s in lazyBois)
            // {
            //     Console.WriteLine(s.firstName);
            // }

            IEnumerable <Student> studentsOrderedByCurrentExerciseCount = students.OrderByDescending(student => student.currentExercises.Count());

            Student hardestWorkinBoi = studentsOrderedByCurrentExerciseCount.Last();

            // Console.WriteLine(hardestWorkinBoi.firstName);

            // How many students in each cohort?

            IEnumerable <Cohort> cohortsOrderedByDescending = cohorts.OrderByDescending(cohorts => cohorts.studentsInCohortList.Count());

            foreach (Cohort cohort in cohortsOrderedByDescending)
            {
                Console.WriteLine($"{cohort.cohortName} has {cohort.studentsInCohortList.Count()} students in it!");
            }



            // foreach (Exercise currentExercise in exercises)
            // {
            //     Console.WriteLine(currentExercise.nameOfExercise);
            //     Console.WriteLine("---------");
            //     List<Student> assignedStudents = students.Where(singleStudent => singleStudent.currentExercises.Any(singleExercise => singleExercise.nameOfExercise == currentExercise.nameOfExercise)).ToList();

            //     assignedStudents.ForEach(singleStudent => Console.WriteLine(singleStudent.firstName));
            //     Console.WriteLine();
            // }
        }
 //assign instructor to a cohort
 static void AssignInstructorCohort(Instructors instructors, Cohort cohort) => cohort.InstructorList.Add(instructors);
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            // OBJECTIVES:
            // Create 4, or more, exercises.
            // Create 3, or more, cohorts.
            // Create 4, or more, students and assign them to one of the cohorts.
            // Create 3, or more, instructors and assign them to one of the cohorts.
            // Have each instructor assign 2 exercises to each of the students.

            var FindRing       = new Exercise("Find a mysterious ring", "CSS");
            var EscapeSpiders  = new Exercise("Escape the spider tunnels", "JavaScript");
            var DragonsLair    = new Exercise("Enter the dragon's lair for treasure", "C#");
            var LonelyMountain = new Exercise("Reclaim the Lonely Mountain for the Dwarves", "C#");

            var Day50 = new Cohort("Day Cohort 50");
            var Eve51 = new Cohort("Evening Cohort 51");
            var Day52 = new Cohort("Day Cohort 52");

            var Bilbo  = new Student("Bilbo", "Baggins", "treasureHunter", "Day Cohort 50");
            var Thorin = new Student("Thorin", "Oakenshield", "kingUnderTheMtn", "Evening Cohort 51");
            var Fili   = new Student("Fili", "Durin", "blueCloak", "Day Cohort 52");
            var Kili   = new Student("Kili", "Durin", "yellowBeard", "Day Cohort 52");

            var Gandalf = new Instructor("Gandalf", "The Grey", "greyWizard", "firework mischief", "Day Cohort 50");
            var Elrond  = new Instructor("Elrond", "Of Rivendale", "waterMagic", "helping hobbits", "Evening Cohort 51");
            var Beorn   = new Instructor("Beorn", "Skinchanger", "bearsRcool", "transforming into a bear", "Day Cohort 52");

            // var JsExer = excercises.Where(exer => exer.ExerLang == "JavaScript");
            // foreach (string exer in excercises)
            // {
            //     Console.WriteLine($"{exer.ExerName} is a JS exercise");
            // }

            /*  PART II: List exercises for the JavaScript language by using the Where() LINQ method.*/


            List <string> excercises = new List <string>()
            {
                "Find a mysterious ring", "Escape the spider tunnels", "Enter the dragon's lair for treasure", "Reclaim the Lonely Mountain for the Dwarves"
            };


            // List instructors in a particular cohort by using the Where() LINQ method.
            List <Instructor> instructors = new List <Instructor>();

            instructors.AddRange(new[] { Gandalf, Elrond, Beorn });
            IEnumerable <Instructor> Cohort32Instructors = Instructor.Where(inst => inst.Cohort == 32);

            /* List students in a particular cohort by using the Where() LINQ method.
             * List instructors in a particular cohort by using the Where() LINQ method.
             * //
             *
             *
             * k
             *
             * Sort the students by their last name.
             * Display any students that aren't working on any exercises (Make sure one of your student instances don't have any exercises. Create a new student if you need to.)
             * Which student is working on the most exercises? Make sure one of your students has more exercises than the others.
             * How many students in each cohort?*/
        }
        static void Main()
        {
            //===============================Create 4 or more exercises==========================
            Exercises exerciseOne   = new Exercises("Iterating Planets", "C#");
            Exercises exerciseTwo   = new Exercises("Kennel", "Reacj.js");
            Exercises exerciseThree = new Exercises("CSS Selectors", "CSS");
            Exercises exerciseFour  = new Exercises("Semantic Tags", "HTML");

            // exerciseOne.ListExercises();
            // exerciseTwo.ListExercises();
            // exerciseThree.ListExercises();
            // exerciseFour.ListExercises();

            Console.WriteLine("=========================================================");

            //=========================Create 3, or more, cohorts.=========================
            Cohort Cohort29 = new Cohort("Cohort29");
            Cohort Cohort30 = new Cohort("Cohort30");
            Cohort Cohort31 = new Cohort("Cohort31");

            //============================Create 4, or more, students=====================
            Student firstStudent  = new Student("Hunter", "Metts", "H-metty");
            Student SecondStudent = new Student("Nick", "Hansen", "nickHanses");
            Student ThirdStudent  = new Student("Asia", "Carter", "AC/DC");
            Student FourthStudent = new Student("Tammy", "toolews", "LoosetGoosey");

            //=====================assign them to one of the cohorts.=========================
            AssignStudentCohort(firstStudent, Cohort29);
            AssignStudentCohort(SecondStudent, Cohort30);
            AssignStudentCohort(ThirdStudent, Cohort31);
            AssignStudentCohort(FourthStudent, Cohort29);

            //=============================Create Three Instructors=============================
            Instructors Jisie = new Instructors("Jisie", "David", "JuiceBox", "Cohort30");
            Instructors Andy  = new Instructors("Andy", "Collins", "Caprisun", "Cohort29");
            Instructors Steve = new Instructors("Steve", "Brownlee", "Gatorade", "Cohort31");

            //ConsoleWrite the list of instructors.
            // Jisie.ListInstructors();
            // Andy.ListInstructors();
            // Steve.ListInstructors();

            //========================assing them to a cohort===================================
            AssignInstructorCohort(Jisie, Cohort30);
            AssignInstructorCohort(Andy, Cohort29);
            AssignInstructorCohort(Steve, Cohort31);

            //Have each instructor assign 2 exercises to each student

            // Cohort 30
            Jisie.AssignExercises(SecondStudent, exerciseTwo);
            Jisie.AssignExercises(SecondStudent, exerciseFour);

            //Cohort 29
            Andy.AssignExercises(firstStudent, exerciseOne);
            Andy.AssignExercises(firstStudent, exerciseFour);

            Andy.AssignExercises(FourthStudent, exerciseFour);
            Andy.AssignExercises(FourthStudent, exerciseTwo);

            //Cohort 31
            Steve.AssignExercises(ThirdStudent, exerciseOne);
            Steve.AssignExercises(ThirdStudent, exerciseThree);

            //student exercise Challenge
            List <Student> students = new List <Student>()
            {
                firstStudent, SecondStudent, ThirdStudent, FourthStudent
            };
            List <Exercises> exercises = new List <Exercises>()
            {
                exerciseOne, exerciseTwo, exerciseThree, exerciseFour
            };

            //Generate a report saying which students are workig on what exercises
            foreach (Student student in students)
            {
                List <string> assignedExercises = new List <string>();

                foreach (Exercises exercise in student.StudentExercises)
                {
                    assignedExercises.Add(exercise.ExerciseName);
                }
                string exerciseList = String.Join(", ", assignedExercises);
                Console.WriteLine($"{student.FirstName} {student.LastName} is working on the following exercises: {exerciseList}");
            }
        }
Exemple #17
0
        static void Main(string[] args)
        {
            //PART 2: After your code where you created all of your instances, add each one to the lists.
            //Create 4, or more, exercises.
            Exercise MyFirstWebpage = new Exercise()
            {
                Name     = "My First Webpage",
                Language = "HTML"
            };

            Exercise FlexboxPractice = new Exercise()
            {
                Name     = "Flexbox Practice",
                Language = "CSS"
            };

            Exercise ArrayMethods = new Exercise()
            {
                Name     = "Array Methods",
                Language = "JavaScript"
            };

            Exercise CSharpOrientation = new Exercise()
            {
                Name     = "Dictionaries and Lists",
                Language = "CSharp"
            };

            List <Exercise> exercises = new List <Exercise>()
            {
                MyFirstWebpage,
                FlexboxPractice,
                ArrayMethods,
                CSharpOrientation
            };

            //Create 3, or more, cohorts.
            Cohort E1  = new Cohort("Evening Cohort 1");
            Cohort C29 = new Cohort("Day Cohort 29");
            Cohort C30 = new Cohort("Day Cohort 30");

            List <Cohort> cohorts = new List <Cohort>()
            {
                E1,
                C29,
                C30
            };

            //Create 4, or more, students and assign them to one of the cohorts.
            Student mary = new Student("Mary", "Remo", "@MaryRemo", C29);

            C29.StudentList.Add(mary);

            Student brittany = new Student("Brittany", "Ramos-Janeway", "@BrittanyRJ", C29);

            C29.StudentList.Add(brittany);

            Student enrique = new Student("Enrique", "Iglesias", "@Enrique", E1);

            E1.StudentList.Add(enrique);

            Student samuel = new Student("Samuel L.", "Jackson", "@SammyJ", C30);

            C30.StudentList.Add(samuel);

            Student gary = new Student("Gary", "Busey", "@gbusey", E1);

            List <Student> students = new List <Student>()
            {
                mary,
                brittany,
                enrique,
                samuel,
                gary
            };

            //Create 3, or more, instructors and assign them to one of the cohorts.
            Instructor andy = new Instructor("Andy", "Collins", "@AndyCollins", C29);

            C29.InstructorList.Add(andy);

            Instructor celine = new Instructor("Celine", "Dion", "@ItsCeline", E1);

            E1.InstructorList.Add(celine);

            Instructor jisie = new Instructor("Jisie", "David", "@Jisie", C30);

            C30.InstructorList.Add(jisie);

            List <Instructor> instructors = new List <Instructor>()
            {
                andy,
                celine,
                jisie
            };

            //List exercises for the JavaScript language by using the Where() LINQ method.
            List <Exercise> JSExercises = (from exercise in exercises
                                           where exercise.Language == "JavaScript"
                                           select exercise).ToList();

            Console.WriteLine("JavaScript Exercises:");
            foreach (Exercise exercise in JSExercises)
            {
                Console.WriteLine(exercise.Name);
            }

            //List students in a particular cohort by using the Where() LINQ method.
            List <Student> C29Students = (from student in students
                                          where student.Cohort == C29
                                          select student).ToList();

            Console.WriteLine("Cohort 29 students:");
            foreach (Student s in C29Students)
            {
                Console.WriteLine(s.FirstName);
            }

            //List instructors in a particular cohort by using the Where() LINQ method.
            List <Instructor> E1Instructors = (from instructor in instructors
                                               where instructor.Cohort == E1
                                               select instructor).ToList();

            Console.WriteLine("Evening Cohort 1 instructors:");
            foreach (Instructor i in E1Instructors)
            {
                Console.WriteLine(i.FirstName);
            }

            //Sort the students by their last name.
            List <Student> StudentsByLastName = (from student in students
                                                 orderby student.LastName
                                                 select student).ToList();

            Console.WriteLine("Students by last name:");
            foreach (Student s in StudentsByLastName)
            {
                Console.WriteLine(s.LastName);
            }

            //Display any students that aren't working on any exercises.
            //(Make sure one of your student instances don't have any exercises. Create a new student if you need to.)
            mary.ExerciseList.Add(MyFirstWebpage);
            brittany.ExerciseList.Add(CSharpOrientation);
            enrique.ExerciseList.Add(FlexboxPractice);
            samuel.ExerciseList.Add(ArrayMethods);

            List <Student> StudentsWithFreeTime = (from student in students
                                                   where student.ExerciseList.Count() == 0
                                                   select student).ToList();

            Console.WriteLine("Students not working on any exercises:");
            foreach (Student s in StudentsWithFreeTime)
            {
                Console.WriteLine(s.FirstName);
            }

            //Which student is working on the most exercises?
            //Make sure one of your students has more exercises than the others.
            mary.ExerciseList.Add(CSharpOrientation);

            List <Student> studentExerciseList = (from student in students
                                                  orderby student.ExerciseList.Count descending
                                                  select student).ToList();

            Student busiestStudent = studentExerciseList.First();

            Console.WriteLine("Student working on the most exercises:");
            Console.WriteLine(busiestStudent.FirstName);

            //How many students in each cohort?
            //CohortCensus defined at top of file
            List <CohortCensus> CohortCount = (from student in students
                                               group student.FirstName by student.Cohort into cohortCensus
                                               select new CohortCensus {
                Cohort = cohortCensus.Key,
                Count = cohortCensus.Count()
            }).ToList();
        }
Exemple #18
0
        static void Main(string[] args)
        {
            var chickenMonkey = new Exercise("ChickenMonkey", "JS");
            var employees     = new Exercise("Company Employees", "C#");
            var stocks        = new Exercise("Stock Exchange", "C#");
            var dailyJournal  = new Exercise("Daily Journal", "React");
            var planner       = new Exercise("Planner", "C#");

            var cohort32 = new Cohort("Cohort 32");
            var cohort28 = new Cohort("Cohort 28");
            var cohort34 = new Cohort("Cohort 34");

            var deep   = new Student("Deep", "Patel", "DP", cohort32);
            var joey   = new Student("Joey", "Driscoll", "JD", cohort32);
            var jason  = new Student("Jason", "Collum", "JC", cohort28);
            var collin = new Student("Collin", "Sandlin", "CS", cohort28);
            var dan    = new Student("Dan", "Storm", "DS", cohort34);
            var sean   = new Student("Sean", "Glavin", "SG", cohort34);

            var adam = new Instructor()
            {
                FirstName   = "Adam",
                LastName    = "Sheaffer",
                SlackHandle = "ADM",
                CohortName  = cohort32,
                Specialty   = "Type Script"
            };

            var bryan = new Instructor()
            {
                FirstName   = "Bryan",
                LastName    = "Neilson",
                SlackHandle = "BRYN",
                CohortName  = cohort34,
                Specialty   = "High Fives"
            };

            var steve = new Instructor()
            {
                FirstName   = "Steve",
                LastName    = "Brownlee",
                SlackHandle = "STV",
                CohortName  = cohort28,
                Specialty   = "Coach"
            };

            adam.AddExercise(deep, employees);
            adam.AddExercise(deep, stocks);
            bryan.AddExercise(deep, chickenMonkey);
            bryan.AddExercise(deep, dailyJournal);
            steve.AddExercise(deep, employees);
            steve.AddExercise(deep, stocks);

            adam.AddExercise(joey, employees);
            adam.AddExercise(joey, stocks);
            bryan.AddExercise(joey, chickenMonkey);
            bryan.AddExercise(joey, dailyJournal);
            steve.AddExercise(joey, employees);
            steve.AddExercise(joey, stocks);

            adam.AddExercise(jason, employees);
            adam.AddExercise(jason, stocks);
            bryan.AddExercise(jason, chickenMonkey);
            bryan.AddExercise(jason, dailyJournal);
            steve.AddExercise(jason, employees);
            steve.AddExercise(jason, stocks);
            steve.AddExercise(jason, planner);

            adam.AddExercise(collin, employees);
            adam.AddExercise(collin, stocks);
            bryan.AddExercise(collin, chickenMonkey);
            bryan.AddExercise(collin, dailyJournal);
            steve.AddExercise(collin, employees);
            steve.AddExercise(collin, stocks);

            // adam.AddExercise(dan, employees);
            // adam.AddExercise(dan, stocks);
            // bryan.AddExercise(dan, chickenMonkey);
            // bryan.AddExercise(dan, dailyJournal);
            // steve.AddExercise(dan, employees);
            // steve.AddExercise(dan, stocks);

            adam.AddExercise(sean, employees);
            adam.AddExercise(sean, stocks);
            bryan.AddExercise(sean, chickenMonkey);
            bryan.AddExercise(sean, dailyJournal);
            steve.AddExercise(sean, employees);
            steve.AddExercise(sean, stocks);

            // var students = new List<Student>();
            // var exercises = new List<Exercise>();

            // students.Add(deep);
            // students.Add(joey);
            // students.Add(jason);
            // students.Add(collin);
            // students.Add(dan);
            // students.Add(sean);

            // exercises.Add(chickenMonkey);
            // exercises.Add(employees);
            // exercises.Add(stocks);
            // exercises.Add(dailyJournal);

            var students = new List <Student>()
            {
                deep,
                joey,
                jason,
                collin,
                dan,
                sean
            };

            var exercises = new List <Exercise>()
            {
                chickenMonkey,
                dailyJournal,
                employees,
                stocks
            };

            var instructors = new List <Instructor>()
            {
                steve,
                adam,
                bryan
            };

            var cohorts = new List <Cohort>()
            {
                cohort28,
                cohort32,
                cohort34
            };

            List <Exercise> javaScript =
                (from exercise in exercises
                 where exercise.Language == "JS"
                 select exercise
                ).ToList();

            List <Student> cohort32Students =
                (from student in students
                 where student.CohortName == cohort32
                 select student
                ).ToList();

            List <Instructor> cohort32Instructors =
                (from instructor in instructors
                 where instructor.CohortName == cohort32
                 select instructor
                ).ToList();

            List <Student> alphabetical = students.OrderBy(student => student.LastName).ToList();

            foreach (Student student in alphabetical)
            {
                Console.WriteLine($"{student.LastName}");
            }

            List <Student> noExercises =
                (from student in students
                 where student.Exercises.Count() == 0
                 select student
                ).ToList();

            foreach (Student student in noExercises)
            {
                Console.WriteLine($"{student.FirstName}");
            }

            List <Student> mostExercises =
                (from student in students
                 //  where student.Exercises.Count()
                 orderby student.Exercises.Count() descending
                 select student
                ).ToList();

            Console.WriteLine($"{mostExercises[0].FirstName} is doing the most exercises");

            List <CohortReport> reports =
                (from student in students
                 group student by student.CohortName into studentGroup
                 select new CohortReport
            {
                CohortName = studentGroup.Key.Name,
                NumberOfStudents = studentGroup.Count()
            }
                ).ToList();

            foreach (CohortReport report in reports)
            {
                Console.WriteLine($"{report.CohortName} has {report.NumberOfStudents} students in it");
            }
        }
        static void Main(string[] args)
        {
            //  Create 4, or more, exercises.
            Exercise lesson1_P = new Exercise("Intro to Python", "Python");
            Exercise lesson2_P = new Exercise("Intermediate Python", "Python");
            Exercise lesson3_P = new Exercise("Advanced Python", "Python");

            Exercise lesson1_C = new Exercise("Intro to C#", "C#");
            Exercise lesson2_C = new Exercise("Intermediate C#", "C#");
            Exercise lesson3_C = new Exercise("Advanced C#", "C#");

            Exercise lesson1_R = new Exercise("Intro to Ruby", "Ruby");
            Exercise lesson2_R = new Exercise("Intermediate Ruby", "Ruby");
            Exercise lesson3_R = new Exercise("Advanced Ruby", "Ruby");
            // Create 3, or more, cohorts.
            Cohort cohort_1 = new Cohort("Cohort_1");
            Cohort cohort_2 = new Cohort("Cohort_2");
            Cohort cohort_3 = new Cohort("Cohort_3");
            // Create 4, or more, students and assign them to one of the cohorts.
            Student student_1 = new Student("Jackie", "Robinson", "JRob", 1);
            Student student_2 = new Student("Bo", "Jackson", "BJack", 2);
            Student student_3 = new Student("Sammy", "Sosa", "SammySosa", 3);
            Student student_4 = new Student("Mark", "McGuire", "BashBro1", 3);
            // Create 3, or more, instructors and...
            Instructor instructor_1 = new Instructor("Brenda", "Long", "BrendaLong", 1, "Javascript");
            Instructor instructor_2 = new Instructor("Adam", "Schaeffer", "AdamRulez", 2, "C#");
            Instructor instructor_3 = new Instructor("Bryan", "Nilsen", "ByanFknNilsen", 3, "Python");

            // ...assign them to one of the cohorts.
            cohort_1.AddToInstructors(instructor_1);
            cohort_2.AddToInstructors(instructor_2);
            cohort_3.AddToInstructors(instructor_3);
            // Have each instructor assign 2 exercises to each of the students.
            instructor_1.addAssignment(student_1, lesson1_C);
            instructor_1.addAssignment(student_1, lesson2_C);
            instructor_1.addAssignment(student_2, lesson1_C);
            instructor_1.addAssignment(student_2, lesson2_C);
            instructor_1.addAssignment(student_3, lesson1_C);
            instructor_1.addAssignment(student_3, lesson2_C);
            instructor_1.addAssignment(student_3, lesson3_C);

            instructor_2.addAssignment(student_1, lesson1_P);
            instructor_2.addAssignment(student_1, lesson2_P);
            instructor_2.addAssignment(student_2, lesson1_P);
            instructor_2.addAssignment(student_2, lesson2_P);
            instructor_2.addAssignment(student_3, lesson1_P);
            instructor_2.addAssignment(student_3, lesson2_P);

            instructor_3.addAssignment(student_1, lesson1_R);
            instructor_3.addAssignment(student_1, lesson2_R);
            instructor_3.addAssignment(student_2, lesson1_R);
            instructor_3.addAssignment(student_2, lesson2_R);
            instructor_3.addAssignment(student_3, lesson1_R);
            instructor_3.addAssignment(student_3, lesson2_R);
            //List of instructors
            List <Instructor> instructor_list = new List <Instructor>();

            instructor_list.Add(instructor_1);
            instructor_list.Add(instructor_2);
            instructor_list.Add(instructor_3);

            // Create a list of students.Add all of the student instances to it.
            List <Student> student_list = new List <Student>();

            student_list.Add(student_1);
            student_list.Add(student_2);
            student_list.Add(student_3);
            student_list.Add(student_4);
            // Create a list of exercises.Add all of the exercise instances to it.
            List <Exercise> exercise_list = new List <Exercise>();

            exercise_list.Add(lesson1_C);
            exercise_list.Add(lesson2_C);
            exercise_list.Add(lesson3_C);
            exercise_list.Add(lesson1_P);
            exercise_list.Add(lesson2_P);
            exercise_list.Add(lesson3_P);
            exercise_list.Add(lesson1_R);
            exercise_list.Add(lesson2_R);
            exercise_list.Add(lesson3_R);
            //List of Cohorts
            List <Cohort> cohorts_list = new List <Cohort>();

            cohorts_list.Add(cohort_1);
            cohorts_list.Add(cohort_2);
            cohorts_list.Add(cohort_3);

            // List exercises for the C# language by using the Where() LINQ method.
            IEnumerable <Exercise> C_lessons = from exercise in exercise_list
                                               where exercise.language == "C#"
                                               select exercise;

            Console.WriteLine("---- Exercises for the C# Language ----");
            foreach (var lesson in C_lessons)
            {
                Console.WriteLine(lesson.name);
            }
            // List students in a particular cohort by using the Where() LINQ method.
            IEnumerable <Student> students_in_C1 = from student in student_list
                                                   where student.studentsCohort == 1
                                                   select student;

            Console.WriteLine("---- Students in Cohort 1 ----");
            foreach (var student in students_in_C1)
            {
                Console.WriteLine(student.firstName + " " + student.lastName);
            }
            // List instructors in a particular cohort by using the Where() LINQ method.
            IEnumerable <Instructor> instructors_in_C1 = from instructor in instructor_list
                                                         where instructor.instructorsCohort == 1
                                                         select instructor;

            Console.WriteLine("---- Instructors in Cohort 1 ----");
            foreach (var instructor in instructors_in_C1)
            {
                Console.WriteLine(instructor.firstName + " " + instructor.lastName);
            }
            // Sort the students by their last name.
            Console.WriteLine("---- Students Sorted by Last Name ----");
            IEnumerable <Student> students_by_lastname = from student in student_list
                                                         orderby student.lastName
                                                         select student;

            foreach (var student in students_by_lastname)
            {
                Console.WriteLine(student.lastName + ", " + student.firstName);
            }
            // Display any students that aren't working on any exercises (Make sure one of your student instances don't have any exercises. Create a new student if you need to.)
            IEnumerable <Student> slacker_students = from student in student_list
                                                     where student.Exercises.Count == 0
                                                     select student;

            Console.WriteLine("---- Students with No Exercises ----");

            foreach (var student in slacker_students)
            {
                Console.WriteLine(student.firstName + " " + student.lastName);
            }
            // Which student is working on the most exercises? Make sure one of your students has more exercises than the others.
            IEnumerable <Student> busiest_student = from student in student_list
                                                    orderby student.Exercises.Count descending
                                                    select student;

            Console.WriteLine("---- Students with Most Exercises ----");
            Student busiest = busiest_student.First();

            Console.WriteLine(busiest.firstName + " " + busiest.lastName);
            // How many students in each cohort?
            Console.WriteLine("---- Cohort Headcount ----");

            foreach (var cohort in cohorts_list)
            {
                Console.WriteLine(cohort.numberOfStudents() + " students are in " + cohort.name);
            }
        }