Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions Icon

Related questions

Question

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<Employee> employees = new List<Employee>() {
                            new Employee("Abha",    "Ford"),
                            new Employee("Krista",  "Honda")
        };

        private static IEnumerable<Student> students = new List<Student>() {
                            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


*/

Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Similar questions
Recommended textbooks for you
Text book image
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Text book image
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Text book image
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Text book image
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Text book image
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Text book image
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY