URGENT!!! Add screenshot of output as well using System; using System.Collections.Generic; namespace Proj1 { //DO NOT add or delete the 'using' directives metioned above. //DO NOT change existing...



URGENT!!!



Add screenshot of output as well




using System;
using System.Collections.Generic;


namespace Proj1
{
    //DO NOT add or delete the 'using' directives metioned above.
    //DO NOT change existing classes and their methods.
    //The expected output from this program is given
    //at the end of this file.



    //Define the methods mySelect and myWhere.
    //You may use a system-defined class in the body of these methods.
    //WRITE CODE BELOW.





    public class Employee
    {
        public string Name { get; set; }
        public string Car { get; set; }
        public Employee(string name, string car)
        { Name = name; Car = car; }
    }


    public class Student
    {
        public string Name { get; set; }
        public string Course { get; set; }
        public Student(string name, string course)
        { Name = name; Course = course; }
    }




    public class Program
    {
        private static IEnumerable employees = new List() {
                            new Employee("Abha",    "Ford"),
                            new Employee("Krista",  "Honda")
        };


        private static IEnumerable students = new List() {
                            new Student("Mellisa",  "Math"),
                            new Student("Camila",   "Bio")
        };




        private static void projectAll()
        {
            Console.WriteLine("************");
            Console.WriteLine("projectAll: ");
            Console.WriteLine("************");


            //projects all attributes.
            var query1 = employees.mySelect( (e) => e );
            foreach (var item in query1)
            {
                Console.WriteLine(item.Name + " " + item.Car);
            }


            var query2 = students.mySelect((e) => e);
            foreach (var item in query2)
            {
                Console.WriteLine(item.Name + " " + item.Course);
            }
        }



        private static void filter()
        {
            Console.WriteLine("********");
            Console.WriteLine("filter: ");
            Console.WriteLine("********");


            //filter on Car == "Honda"
            var query1 = employees.myWhere( (e) => e.Car == "Honda" );
            foreach (var item in query1)
            {
                Console.WriteLine(item.Name);
            }


            //filter on Course == "Math"
            var query2 = students.myWhere((e) => e.Course == "Math");
            foreach (var item in query2)
            {
                Console.WriteLine(item.Name);
            }
        }




        public static void Main(string[] args)
        {
            projectAll();
            Console.WriteLine("");

            filter();
            Console.WriteLine("");


            Console.ReadKey(); //halt execution
        }
    }
}


/*

The output from the above program should be as follows.



************
projectAll:
************
Abha Ford
Krista Honda
Mellisa Math
Camila Bio


*************
projectName:
*************
Abha
Krista
Mellisa
Camila


********
filter:
********
Krista
Mellisa




*/

Jun 06, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here