static void Main(string[] args) { Exercise Exercise1 = new Exercise("Sandwich Maker", "Javascript"); Exercise Exercise2 = new Exercise("Tamagotchi", "Sass"); Exercise Exercise3 = new Exercise("Sports Roster", "ReactJS"); Exercise Exercise4 = new Exercise("Heist", "Csharp"); ///////////////// Cohort Cohort37 = new Cohort("C37"); Cohort CohortE10 = new Cohort("E10"); Cohort Cohort35 = new Cohort("C35"); //////////////////// Student Jasmine = new Student("Williams", "Jasmine", "williaj", Cohort37); Student Maggie = new Student("Greene", "Maggie", "maggieg", Cohort37); Student Crystal = new Student("Broach", "Crystal", "broach44", CohortE10); Student Ashley = new Student("Claiborne", "Ashley", "ac1986", Cohort35); /////////////////// Instructor Adam = new Instructor("Adam", "Sheaffer", "asheaff", Cohort37, "blackboxes"); Instructor Brenda = new Instructor("Brenda", "Long", "blong", Cohort35, "star wars"); Instructor Rose = new Instructor("Rose", "Wiz", "rwizzy", CohortE10, "fashion"); /////////////////// Adam.Assign(Exercise1, Exercise2, Jasmine); Adam.Assign(Exercise1, Exercise2, Maggie); Adam.Assign(Exercise1, Exercise2, Crystal); Adam.Assign(Exercise1, Exercise2, Ashley); Brenda.Assign(Exercise2, Exercise3, Jasmine); Brenda.Assign(Exercise2, Exercise3, Maggie); Brenda.Assign(Exercise2, Exercise3, Crystal); Brenda.Assign(Exercise2, Exercise3, Ashley); Rose.Assign(Exercise3, Exercise4, Jasmine); Rose.Assign(Exercise3, Exercise4, Maggie); Rose.Assign(Exercise3, Exercise4, Crystal); Rose.Assign(Exercise3, Exercise4, Ashley); ////////////////////// List <Student> students = new List <Student> { Jasmine, Maggie, Crystal, Ashley }; List <Exercise> exercises = new List <Exercise> { Exercise1, Exercise2, Exercise3, Exercise4 }; }
static void Main(string[] args) { Exercise ChickenMonkey = new Exercise("Chicken Monkey", "Javascript"); Exercise CoinsToCash = new Exercise("Coins to Cash", "Javascript"); Exercise StudentExercises = new Exercise("Student Exercises", "C#"); Exercise Nutshell = new Exercise("Nutshell", "C#"); Cohort ThirtyFour = new Cohort("34"); Cohort ThirtyFive = new Cohort("35"); Cohort ThirtySix = new Cohort("36"); Student Will = new Student("Will", "Wilkerson", "WILLSLACK"); Student Noah = new Student("Noah", "Bartfield", "NOAHSLACK"); Student Brantley = new Student("Brantley", "Jones", "BRANTLEYSLACK"); Student Bobby = new Student("Bobby", "Brady", "BOBBYSLACK"); Student Ted = new Student("Ted", "Rooselvelt", "TEDSLACK"); ThirtyFive.AddStudent(Will); ThirtyFive.AddStudent(Brantley); ThirtyFour.AddStudent(Noah); ThirtySix.AddStudent(Bobby); ThirtySix.AddStudent(Ted); Instructor Andy = new Instructor("Andy", "Collins", "ANDYSLACK", "Pointing"); Instructor Jenna = new Instructor("Jenna", "Solis", "JENNASLACK", "Killing animals"); Instructor Bryan = new Instructor("Bryan", "Nilsen", "ANDYSLACK", "High fives"); ThirtyFive.AddInstructor(Andy); ThirtySix.AddInstructor(Jenna); ThirtyFour.AddInstructor(Bryan); Andy.Assign(Bobby, ChickenMonkey); Andy.Assign(Bobby, CoinsToCash); Andy.Assign(Noah, ChickenMonkey); Jenna.Assign(Noah, Nutshell); Jenna.Assign(Will, Nutshell); Jenna.Assign(Will, ChickenMonkey); Bryan.Assign(Will, StudentExercises); Bryan.Assign(Brantley, CoinsToCash); Bryan.Assign(Brantley, StudentExercises); List <Student> students = new List <Student>(); students.Add(Will); students.Add(Noah); students.Add(Brantley); students.Add(Bobby); students.Add(Ted); List <Instructor> instructors = new List <Instructor>(); instructors.Add(Andy); instructors.Add(Jenna); instructors.Add(Bryan); List <Exercise> exercises = new List <Exercise>(); exercises.Add(ChickenMonkey); exercises.Add(Nutshell); exercises.Add(StudentExercises); exercises.Add(CoinsToCash); Console.WriteLine("- - - - - - - - - - - - - - - - - - - - - - - - -"); List <Exercise> JSExercises = exercises.Where(exercise => exercise.Langauge == "Javascript").ToList(); foreach (Exercise exercise in JSExercises) { Console.WriteLine(exercise.Name); } List <Student> c34 = students.Where(student => student.Cohort.Name == "34").ToList(); List <Instructor> c34I = instructors.Where(instructor => instructor.Cohort.Name == "34").ToList(); List <Student> c35 = students.Where(student => student.Cohort.Name == "35").ToList(); List <Instructor> c35I = instructors.Where(instructor => instructor.Cohort.Name == "35").ToList(); List <Student> c36 = students.Where(student => student.Cohort.Name == "36").ToList(); List <Instructor> c36I = instructors.Where(instructor => instructor.Cohort.Name == "36").ToList(); List <Student> LastName = students.OrderBy(student => student.LastName).ToList(); List <Student> NoExercises = students.Where(student => student.Exercises.Count == 0).ToList(); List <Student> MostExercises = students.OrderByDescending(student => student.Exercises.Count).ToList(); foreach (Student student in c34) { Console.WriteLine("- - - - - - - - - - - -"); Console.WriteLine("Cohort 34 Students"); Console.WriteLine($"{student.FirstName} {student.LastName}"); Console.WriteLine(c34.Count()); Console.WriteLine("- - - - - - - - - - - -"); } Console.WriteLine("Cohort 35 Students"); foreach (Student student in c35) { Console.WriteLine($"{student.FirstName} {student.LastName}"); } Console.WriteLine(c35.Count()); Console.WriteLine("- - - - - - - - - - - -"); Console.WriteLine("Cohort 36 Students"); foreach (Student student in c36) { Console.WriteLine($"{student.FirstName} {student.LastName}"); } Console.WriteLine(c36.Count()); Console.WriteLine("- - - - - - - - - - - -"); Console.WriteLine("Cohort 34 Instructors"); foreach (Instructor instructor in c34I) { Console.WriteLine($"{instructor.FirstName} {instructor.LastName}"); } Console.WriteLine("- - - - - - - - - - - -"); Console.WriteLine("Cohort 35 Instructors"); foreach (Instructor instructor in c35I) { Console.WriteLine($"{instructor.FirstName} {instructor.LastName}"); } Console.WriteLine("- - - - - - - - - - - -"); Console.WriteLine("Cohort 36 Instructors"); foreach (Instructor instructor in c36I) { Console.WriteLine($"{instructor.FirstName} {instructor.LastName}"); } Console.WriteLine("- - - - - - - - - - - -"); Console.WriteLine("Sorted By Last Name"); foreach (Student student in LastName) { Console.WriteLine($"{student.FirstName} {student.LastName}"); } Console.WriteLine("- - - - - - - - - - - -"); foreach (Student student in NoExercises) { Console.WriteLine($"No Exercises for {student.FirstName} {student.LastName}"); Console.WriteLine("- - - - - - - - - - - -"); } Console.WriteLine($"The student with the most exercises is {MostExercises[0].FirstName} {MostExercises[0].LastName}"); // Console.WriteLine("Report:"); // foreach (Student student in students) // { // foreach (Exercise exercise in student.Exercises) // { // Console.WriteLine($"{student.FirstName} {student.LastName} is working on {exercise.Name}."); // } // } Console.WriteLine("- - - - - - - - - - - - - - - - - - - - - - - - -"); }
static void Main(string[] args) { var FizzBuzz = new Exercise() { Name = "FizzBuzz", Language = "Javascript" }; var UrbanPlanner = new Exercise() { Name = "UrbanPlanner", Language = "C#" }; var Kennel = new Exercise() { Name = "Kennel", Language = "React" }; var DailyJournal = new Exercise() { Name = "DailyJournal", Language = "Javascript" }; var StudentExercises = new Exercise() { Name = "StudentExercises", Language = "C#" }; var cohort32 = new Cohort() { Name = "Cohort 32" }; var cohort33 = new Cohort() { Name = "Cohort 33" }; var cohort34 = new Cohort() { Name = "Cohort34" }; var jWebb = new Student() { FirstName = "Josh", LastName = "Webb", Slack = "Josh-Webb", Cohort = cohort32 }; var eClarke = new Student() { FirstName = "Eliot", LastName = "Clarke", Slack = "Eliot", Cohort = cohort32 }; var eAshe = new Student() { FirstName = "Ellie", LastName = "Ashe", Slack = "Ellie-Ashe", Cohort = cohort34 }; var kCard = new Student() { FirstName = "Keisha", LastName = "Card", Slack = "Keisha C", Cohort = cohort33 }; var dSteponawich = new Student() { FirstName = "Dejan", LastName = "Stepfonavich", Slack = "Dejan S", Cohort = cohort34 }; var oPlank = new Student() { FirstName = "Olivia", LastName = "Plank", Slack = "Soft Boi", Cohort = cohort33 }; var bNilsen = new Instructor() { FirstName = "Bryan", LastName = "Wilson", Slack = "Bryan Nilsen", Cohort = cohort34, Speciality = "High Fives" }; var rHecht = new Instructor() { FirstName = "Robbie", LastName = "Hecht", Slack = "Robbiehecht", Cohort = cohort32, Speciality = "Singer/Song-writer" }; var aShaefer = new Instructor() { FirstName = "Addam", LastName = "Shaefer", Slack = "Addam Shaefer", Cohort = cohort33, Speciality = "Hats" }; List <Student> students = new List <Student>() { eAshe, kCard, dSteponawich, eClarke, jWebb, oPlank }; List <Exercise> exercises = new List <Exercise>() { FizzBuzz, UrbanPlanner, Kennel, DailyJournal, StudentExercises }; List <Instructor> instructors = new List <Instructor>() { bNilsen, aShaefer, rHecht }; foreach (Exercise exercise in exercises) { Console.WriteLine($"{exercise.Name}"); } ; foreach (Student student in students) { Console.WriteLine($"{student.FirstName}"); } ; bNilsen.Assign(FizzBuzz, eAshe); bNilsen.Assign(DailyJournal, eAshe); bNilsen.Assign(Kennel, kCard); bNilsen.Assign(UrbanPlanner, kCard); bNilsen.Assign(StudentExercises, dSteponawich); bNilsen.Assign(Kennel, dSteponawich); bNilsen.Assign(DailyJournal, eClarke); bNilsen.Assign(Kennel, eClarke); bNilsen.Assign(StudentExercises, jWebb); bNilsen.Assign(UrbanPlanner, jWebb); bNilsen.Assign(DailyJournal, jWebb); rHecht.Assign(Kennel, eAshe); rHecht.Assign(DailyJournal, eAshe); rHecht.Assign(FizzBuzz, kCard); rHecht.Assign(DailyJournal, kCard); rHecht.Assign(UrbanPlanner, dSteponawich); rHecht.Assign(FizzBuzz, dSteponawich); rHecht.Assign(StudentExercises, eClarke); rHecht.Assign(DailyJournal, eClarke); rHecht.Assign(Kennel, jWebb); rHecht.Assign(FizzBuzz, jWebb); aShaefer.Assign(UrbanPlanner, eAshe); aShaefer.Assign(StudentExercises, eAshe); aShaefer.Assign(StudentExercises, kCard); aShaefer.Assign(UrbanPlanner, kCard); aShaefer.Assign(StudentExercises, dSteponawich); aShaefer.Assign(Kennel, dSteponawich); aShaefer.Assign(DailyJournal, eClarke); aShaefer.Assign(Kennel, eClarke); aShaefer.Assign(StudentExercises, jWebb); aShaefer.Assign(UrbanPlanner, jWebb); cohort32.Students.Add(jWebb); cohort32.Students.Add(eClarke); cohort33.Students.Add(kCard); cohort33.Students.Add(oPlank); cohort34.Students.Add(dSteponawich); cohort34.Students.Add(eAshe); List <Cohort> cohorts = new List <Cohort>() { cohort32, cohort33, cohort34 }; foreach (Student student in students) { Console.WriteLine($"{student.FirstName} is working on"); foreach (Exercise exercise in student.Exercises) { Console.WriteLine($"{exercise.Name}"); } } Console.WriteLine($"Exercise 1 is {exercises[0].Name}"); IEnumerable <Exercise> javascriptExercises = from exercise in exercises where exercise.Language == "Javascript" select exercise; foreach (Exercise e in javascriptExercises) { Console.WriteLine($"{e.Name} ${e.Language}"); } IEnumerable <Student> cohort32List = from student in students where student.Cohort == cohort32 select student; foreach (Student s in cohort32List) { Console.WriteLine($"{s.FirstName} {s.LastName} is in Cohort 32."); } IEnumerable <Instructor> cohort32Instructors = from instructor in instructors where instructor.Cohort == cohort32 select instructor; foreach (Instructor i in cohort32Instructors) { Console.WriteLine($"{i.FirstName} {i.LastName} is an instructor for Cohort 32"); } IEnumerable <Student> orderLastName = from student in students orderby student.LastName select student; foreach (Student s in orderLastName) { Console.WriteLine($"{s.LastName}, {s.FirstName}"); } IEnumerable <Student> noExercises = from student in students where student.Exercises.Count == 0 select student; foreach (Student s in noExercises) { Console.WriteLine($"{s.FirstName} {s.LastName} doesn't have any exercises."); } var mostExercises = students.OrderByDescending(student => student.Exercises.Count()).Take(1); foreach (Student s in mostExercises) { Console.WriteLine($"{s.FirstName} {s.LastName} has the most exercises."); } foreach (var cohort in cohorts) { Console.WriteLine($"{cohort.Name} has {cohort.Students.Count()} students."); } }
static void Main(string[] args) { // EXERCISES Exercise ClassesExercise = new Exercise("ClassesExercise", "C#"); Exercise ListsExercises = new Exercise("ListsExercises", "C#"); Exercise Dictionaries = new Exercise("Dictionaries", "C#"); Exercise Sets = new Exercise("Sets", "C#"); List <Exercise> exercises = new List <Exercise>() { ClassesExercise, ListsExercises, Dictionaries, Sets }; // COHORT Cohort Cohort1 = new Cohort(); Cohort Cohort2 = new Cohort(); Cohort Cohort3 = new Cohort(); Cohort Cohort4 = new Cohort(); List <Cohort> cohorts = new List <Cohort>() { Cohort1, Cohort2, Cohort3, Cohort4 }; // STUDENT Student Mary = new Student("Mary", "Remo", "maryremo", "Cohort1"); Student Asia = new Student("Asia", "Carter", "asiacarter", "Cohort2"); Student Ash = new Student("Ash", "Prakash", "ash", "Cohort3"); Student Cole = new Student("Cole", "Bryant", "colebryant", "Cohort4"); List <Student> students = new List <Student>() { Mary, Asia, Ash, Cole }; // INSTRUCTOR Instructor Jisie = new Instructor("Jisie", "David", "@jisie", "Cohort1"); Instructor Andy = new Instructor("Andy", "Collins", "@aNDY", "Cohort2"); Instructor Steve = new Instructor("Steve", "Brownlee", "@steve", "Cohort3"); List <Instructor> instructors = new List <Instructor>() { Jisie, Andy, Steve }; Steve.Assign(Cole, Dictionaries); Steve.Assign(Cole, ListsExercises); Andy.Assign(Asia, Dictionaries); Andy.Assign(Asia, ListsExercises); Andy.Assign(Mary, Dictionaries); Andy.Assign(Mary, ListsExercises); // Jisie.Assign(Ash, Dictionaries); // Jisie.Assign(Ash, ListsExercises); List <Exercise> JSExercises = (from exercise in exercises where exercise.Language == "Javascript" select exercise).ToList(); List <Student> Cohort2Students = (from student in students where student.CohortNumber == "Cohort2" select student ).ToList(); Console.WriteLine(Cohort2Students); List <Instructor> Cohort3Instructor = (from instructor in instructors where instructor.CohortNumber == "Cohort3" select instructor).ToList(); List <Student> StudentsByLastName = (from student in students orderby student.LastName select student).ToList(); List <Student> StudentWithoutExercises = (from student in students where student.Exercises.Count() == 0 select student).ToList(); List <Student> StudentWithMostExercises = (from student in students orderby student.Exercises.Count descending select student).ToList(); List <CohortRoster> StudentsInCohort = (from student in students group student.FirstName by student.CohortNumber into cohortRoster select new CohortRoster { CohortNumber = cohortRoster.Key, StudentCount = cohortRoster.Count() }).ToList(); }
static void Main(string[] args) { // EXERCISES Exercise Exercise1 = new Exercise(); Exercise1.Name = "Exercise1"; Exercise1.Language = "C#"; Exercise Exercise2 = new Exercise(); Exercise2.Name = "Execrcise2"; Exercise2.Language = "C#"; Exercise Exercise3 = new Exercise(); Exercise3.Name = "Exercise3"; Exercise3.Language = "C#"; Exercise Exercise4 = new Exercise(); Exercise4.Name = "Exercise4"; Exercise4.Language = "C#"; // COHORT Cohort Cohort1 = new Cohort(); Cohort Cohort2 = new Cohort(); Cohort Cohort3 = new Cohort(); Cohort Cohort4 = new Cohort(); // STUDENT Student Dan = new Student(); Dan.FirstName = "Dan"; Dan.LastName = "Brewer"; Dan.SlackHandle = "danbrewer"; Student Asia = new Student(); Asia.FirstName = "Asia"; Asia.LastName = "Carter"; Asia.SlackHandle = "asiacarter"; Student Brittany = new Student(); Brittany.FirstName = "Brittany"; Brittany.LastName = "Ramos-Janeway"; Brittany.SlackHandle = "brittanyramos-janeway"; Student Austin = new Student(); Austin.FirstName = "Austin"; Austin.LastName = "Blade"; Austin.SlackHandle = "austinblade"; Student Megan = new Student(); Megan.FirstName = "Megan"; Megan.LastName = "Cruzen"; Megan.SlackHandle = "megancruzen"; Student Cole = new Student(); Cole.FirstName = "Cole"; Cole.LastName = "Bryant"; Cole.SlackHandle = "colebryant"; Student Mary = new Student(); Mary.FirstName = "Mary"; Mary.LastName = "Remo"; Mary.SlackHandle = "maryremo"; Student Allison = new Student(); Allison.FirstName = "Allison"; Allison.LastName = "Collins"; Allison.SlackHandle = "allisoncollins"; Student JD = new Student(); JD.FirstName = "JD"; JD.LastName = "Wheeler"; JD.SlackHandle = "JDWheeler"; // Create Student List Cohort1.Students = new List <Student>(); Cohort2.Students = new List <Student>(); Cohort3.Students = new List <Student>(); Cohort4.Students = new List <Student>(); Cohort1.Students.Add(Dan); Cohort2.Students.Add(Asia); Cohort3.Students.Add(Brittany); Cohort4.Students.Add(Austin); Cohort1.Students.Add(Megan); Cohort2.Students.Add(Cole); Cohort3.Students.Add(Mary); Cohort4.Students.Add(Allison); Cohort1.Students.Add(JD); // INSTRUCTOR Instructor Andy = new Instructor(); Andy.FirstName = "Andy"; Andy.LastName = "Collins"; Andy.SlackHandle = "AndyCollins"; Instructor Jisie = new Instructor(); Jisie.FirstName = "Jisie"; Jisie.LastName = "David"; Jisie.SlackHandle = "JisieDavid"; Instructor Steve = new Instructor(); Steve.FirstName = "Steve"; Steve.LastName = "Brownlee"; Steve.SlackHandle = "SteveBrownlee"; Instructor Brenda = new Instructor(); Brenda.FirstName = "Brenda"; Brenda.LastName = "Long"; Brenda.SlackHandle = "brendalong"; // Create Instructor List Cohort1.Instructors = new List <Instructor>(); Cohort2.Instructors = new List <Instructor>(); Cohort3.Instructors = new List <Instructor>(); Cohort4.Instructors = new List <Instructor>(); Cohort1.Instructors.Add(Andy); Cohort2.Instructors.Add(Jisie); Cohort3.Instructors.Add(Steve); Cohort4.Instructors.Add(Brenda); // Create Cohort List List <Cohort> Cohorts = new List <Cohort>(); Cohorts.Add(Cohort1); Cohorts.Add(Cohort2); Cohorts.Add(Cohort3); Cohorts.Add(Cohort4); Brenda.Assign(Austin, Exercise2); Brenda.Assign(Allison, Exercise3); Steve.Assign(Mary, Exercise2); Steve.Assign(Brittany, Exercise3); Andy.Assign(Dan, Exercise1); Andy.Assign(Megan, Exercise3); Andy.Assign(JD, Exercise2); Andy.Assign(Dan, Exercise3); Jisie.Assign(Cole, Exercise2); Jisie.Assign(Asia, Exercise4); // Challenge - Create a list of students. Add all of the student instances to it. foreach (Cohort cohort in Cohorts) { List <Student> students = new List <Student>(); foreach (Student student in cohort.Students) { students.Add(student); List <Exercise> exercises = new List <Exercise>(); foreach (Exercise exercise in student.Exercises) { exercises.Add(exercise); Console.WriteLine($"{student.FirstName} is working on {exercise.Name}"); } } } }
static void Main(string[] args) { // created 4 exercises Exercise Classes = new Exercise("Classes", "C#"); Exercise Lists = new Exercise("Lists", "Python"); Exercise Dictionaries = new Exercise("Dictionaries", "Python"); Exercise HashSets = new Exercise("HashSets", "C#"); Exercise OverlyExcited = new Exercise("OverlyExcited", "JavaScript"); Exercise ChickenMonkey = new Exercise("ChickenMonkey", "JavaScript"); // created 3 cohorts Cohort TwentySeven = new Cohort("Day Cohort 27"); Cohort TwentyEight = new Cohort("Day Cohort 28"); Cohort TwentyFive = new Cohort("Day Cohort 25"); // created 4 students Student Madi = new Student("Madi", "Peper", "MadiPeper", TwentySeven.Name); Student Jonathan = new Student("Jonathan", "Edwards", "PraiseBe", TwentySeven.Name); Student Cashew = new Student("Cashew", "Agnoletti", "Cashew", TwentyFive.Name); Student Elyse = new Student("Elyse", "Dawson", "ElyseDawson", TwentyEight.Name); Student Alejandro = new Student("Alejandro", "Font", "high-waters", TwentySeven.Name); Student Kayla = new Student("Kayla", "Reid", "k.reid", TwentySeven.Name); // created 3 instructors Instructor Steve = new Instructor("Steve", "Brownlee", "stevebrownlee", TwentySeven.Name); Instructor Meg = new Instructor("Meg", "Ducharme", "megducharme", TwentySeven.Name); Instructor Jenna = new Instructor("Jenna", "Solis", "JennaSolis", TwentyEight.Name); // assign 2 exercises to 3 students Steve.Assign(Madi, Classes); Steve.Assign(Madi, HashSets); Steve.Assign(Madi, OverlyExcited); Meg.Assign(Madi, ChickenMonkey); Meg.Assign(Jonathan, Classes); Meg.Assign(Jonathan, HashSets); Meg.Assign(Jonathan, ChickenMonkey); Jenna.Assign(Elyse, Classes); Jenna.Assign(Elyse, Lists); List <Student> StudentList = new List <Student>() { // added students to the student list that was created Madi, Jonathan, Cashew, Elyse }; List <Exercise> AllExercises = new List <Exercise>() { // added exercises to the exercise list that was created Classes, Lists, Dictionaries, HashSets }; // loop through the list of students foreach (Student student in StudentList) { // loop through the list of exercises foreach (Exercise exercise in AllExercises) { /* * If the student's exercise list contains the current exercise, then print the student's first name and the exercise they're working on */ if (student.ExerciseList.Contains(exercise)) { Console.WriteLine($"{student.FirstName} is currently working on {exercise.Name}"); } } } /* * ☑️ 1. List exercises for the JavaScript language by using the Where() LINQ method. * ☑️ 2. List students in a particular cohort by using the Where() LINQ method. * ☑️ 3. List instructors in a particular cohort by using the Where() LINQ method. * ☑️ 4. Sort the students by their last name. * ☑️ 5. 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.) * ☑️ 6. Which student is working on the most exercises? Make sure one of your students has more exercises than the others. * ☑️ 7. How many students in each cohort? */ Console.WriteLine("////////// Student Exercise Pt. 2 //////////"); List <Student> students = new List <Student>() { Madi, Jonathan, Cashew, Elyse, Kayla, Alejandro }; List <Instructor> instructors = new List <Instructor>() { Steve, Jenna, Meg }; List <Exercise> exercises = new List <Exercise>() { Classes, Lists, Dictionaries, HashSets, ChickenMonkey, OverlyExcited }; List <Cohort> cohorts = new List <Cohort>() { TwentyEight, TwentySeven, TwentyFive }; Console.WriteLine("///// JavaScript Exercises /////"); List <Exercise> JSExercises = (from e in exercises where e.Language.Contains("JavaScript") select e).ToList(); JSExercises.ForEach(e => Console.WriteLine(e.Name)); Console.WriteLine("///// Students in 27 /////"); List <Student> TwentySevenStudents = (from s in students where s.Cohort.Contains("27") select s).ToList(); TwentySevenStudents.ForEach(s => Console.WriteLine(s.FullName)); Console.WriteLine("///// Instructors in 27 /////"); List <Instructor> TwentySevenInstructors = (from i in instructors where i.CohortName.Contains("27") select i).ToList(); TwentySevenInstructors.ForEach(i => Console.WriteLine(i.FirstName)); Console.WriteLine("///// Sort Students by Last Name /////"); List <Student> lastNames = (from s in students orderby s.LastName ascending select s).ToList(); lastNames.ForEach(s => Console.WriteLine(s.FullName)); Console.WriteLine("///// Students w/o Exercise /////"); List <Student> noExercises = (from s in students where s.ExerciseList.Count() == 0 select s).ToList(); noExercises.ForEach(student => Console.WriteLine($"{student.FirstName} does not have an exercise!")); Console.WriteLine("///// Most Exercises per Student /////"); List <Student> mostExercises = (from s in students orderby s.ExerciseList.Count() descending select s).ToList(); Console.WriteLine($"{mostExercises.First().FirstName} has the most exercises."); Console.WriteLine("///// How many students per Cohort? /////"); // using var here because it is making an anonymous object var totalStudents = from student in students group student by student.Cohort into sortedStudents select new { Cohort = sortedStudents.Key, Students = sortedStudents.ToList() }; foreach (var total in totalStudents) { Console.WriteLine($"Cohort {total.Cohort} has {total.Students.Count()} students."); } Console.WriteLine("////////// Students Exercise Pt. 4 //////////"); SqliteConnection db = DatabaseInterface.Connection; List <Exercise> DBexercises = db.Query <Exercise>(@"SELECT * FROM Exercise").ToList(); DBexercises.ForEach(exer => Console.WriteLine($"Exercises: {exer.Name}")); db.Query <Exercise>(@" SELECT * FROM Exercise WHERE Language='JavaScript'") .ToList() .ForEach(exer => Console.WriteLine($"Javascript Exercise: {exer.Name}")); // CODE HAS ALREADY BEEN EXECUTED // db.Execute($@" // INSERT INTO Exercise ('Name', 'Language') VALUES ('Student Exercises', 'C#')"); db.Query <Instructor, Cohort, Instructor>(@" SELECT i.Id, i.FirstName, i.LastName, i.SlackHandle, c.Id, c.CohortName FROM Instructors i JOIN Cohort c ON c.Id = i.CohortId", (instructor, cohort) => { instructor.CohortName = cohort.CohortName; return(instructor); }) .ToList() .ForEach(ins => Console.WriteLine($"{ins.FirstName} {ins.LastName} is currently an instructor for {ins.CohortName}")); // CODE HAS ALREADY BEEN EXECUTED // db.Execute(@" // INSERT INTO Instructors (FirstName, LastName, SlackHandle, CohortId) // VALUES('Jisie', 'David', 'jisie', 2)"); // CODE HAS ALREADY BEEN EXECUTED // db.Execute(@" // INSERT INTO StudentExercise (StudentId, ExerciseId) VALUES (1, 5)"); }