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) { 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) { // 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); } }
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(); // } }
//Methods public void AddToInstructors(Instructor new_instructor) { _instructors.Add(new_instructor); }