using System.Collections.Generic; namespace LinqActivity { class Program { static void Main(string[] args) { Console.WriteLine("LINQ Activity - 2/23/2024"); Console.WriteLine("Name: INSERT NAME HERE"); List patients = new List { new Patient("John", 25, 5, 8, 180, new DateTime(2022,2, 18)), new Patient("Jane", 30, 5, 5, 150, new DateTime(2023,1, 10)), new Patient("Joe", 28, 6, 0, 200, new DateTime(2020, 7, 23)), new Patient("Jill", 35, 5, 7, 160, new DateTime(2021, 3, 20)), new Patient("Jack", 40, 5, 10, 190, new DateTime(2022, 8, 1)) }; List transferPatients = new List { new Patient("Bobby", 35, 5, 8, 180, new DateTime(2022,2, 18)), new Patient("Jamison", 33, 5, 5, 150, new DateTime(2023,1, 10)), new Patient("Elijah", 48, 6, 0, 200, new DateTime(2020, 7, 23)), new Patient("Bill", 15, 5, 7, 160, new DateTime(2021, 3, 20)), new Patient("Jack", 40, 5, 10, 190, new DateTime(2022, 8, 1)), new Patient("Jack", 40, 5, 10, 190, new DateTime(2022, 8, 1)) }; Console.WriteLine("\nAll Patients in the Patients list"); DisplayPatients(patients); Console.WriteLine("\n1.) All Patients over 30 in the Patients list"); //1.) Write a LINQ query that returns all patients over the age of 30 in the "Patients" list var test1 = AllPatientsOver30(patients); DisplayPatients(test1); //2.) Write a LINQ query that takes the patients in the Patients list, and returns a string of their names separated by a comma Console.WriteLine("\n2.) All Patient Names"); Console.WriteLine(AllPatientNames(patients)); //3.) Write a LINQ query that returns the average weight of all patients in the Patients list Console.WriteLine("\n3.) Average Weight of All Patients"); Console.WriteLine(AverageWeightOfAllPatients(patients)); //4.) Write a LINQ query that orders the list of patients in the Patients list by DateCreated and returns the most recent Console.WriteLine("\n4.) Most Recent Patient Created"); var mostRecentPatient = MostRecentPatientCreated(patients); Console.WriteLine(mostRecentPatient?.ToString() ?? "Patient is NULL"); //5.) Write a LINQ Query that concatenates the two lists of patients together Console.WriteLine("\n5.) Concatenate Patient Lists"); var joinedPatientLists = ConcatPatientLists(patients, transferPatients); DisplayPatients(joinedPatientLists); //6.)Given the last of transferParentNames below, write a LINQ Query within DistinctTransferPatients that returns a list of distinct names Console.WriteLine("\n6.) Distinct Transfer Patients"); var transferPatientNames = transferPatients.Select(p => p.Name).ToList(); var distinctTransferPatientsNames = DistinctTransferPatients(transferPatientNames); if(distinctTransferPatientsNames!=null) Console.WriteLine(string.Join(", ", distinctTransferPatientsNames)); //7.) Write a LINQ Query that checks if the list of patients contains ANY patients with the name "Joe" Console.WriteLine("\n7.) Contains Joe?"); Console.WriteLine(ContainsJoe(patients)); //8.) Write a LINQ Query that TAKEs the first 3 patients in the patient list Console.WriteLine("\n8.) First 3 Patients"); var first3Patients = First3Patients(patients); DisplayPatients(first3Patients); }//END Main public static void DisplayPatients(List patients) { if (patients == null) { Console.WriteLine("Patient List Provided is NULL :O"); return; } foreach (var patient in patients) { Console.WriteLine($"Name: {patient.Name}, Age: {patient.Age}, Height: {patient.HeightFeet}'{patient.HeightInches}\", Weight: {patient.Weight} lbs, DateCreated: {patient.DateCreated.ToString("MMddyyyy")}."); } } public static List AllPatientsOver30(List patients) { return null; } public static string AllPatientNames(List patients) { return null; } public static decimal AverageWeightOfAllPatients(List patients) { return 0; } public static Patient MostRecentPatientCreated(List patients) { return null; } public static List ConcatPatientLists(List patients, List transferPatients) { return null; } public static List DistinctTransferPatients(List transferPatientNames) { return null; } public static bool ContainsJoe(List patients) { return false; } public static List First3Patients(List patients) { return null; } } public class Patient { public Patient(string name, int age, int heightFeet, int heightInches, decimal weight, DateTime dateCreated) { Name = name; Age = age; HeightFeet = heightFeet; HeightInches = heightInches; Weight = weight; DateCreated = dateCreated; } public override string ToString() { return $"Name: {Name}, Age: {Age}, Height: {HeightFeet}'{HeightInches}\", Weight: {Weight} lbs, DateCreated: {DateCreated.ToString("MMddyyyy")}."; } public string Name { get; set; } public int Age { get; set; } public int HeightFeet { get; set; } public int HeightInches { get; set; } public decimal Weight { get; set; } public DateTime DateCreated { get; set; } } }