static void Main(string[] args)
        {
            var departments = new DepartmentCollection();


            departments.Add("Sales", new Employee {
                Name = "Tyler"
            })
            .Add("Sales", new Employee {
                Name = "Taylor"
            })
            .Add("Engineering", new Employee {
                Name = "Sean"
            })
            .Add("Engineering", new Employee {
                Name = "Connor"
            })
            .Add("Engineering", new Employee {
                Name = "Cody"
            });



            foreach (var department in departments)
            {
                Console.WriteLine(department.Key);
                foreach (var employee in department.Value)
                {
                    Console.WriteLine($"\t{employee.Name}");
                }
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            DepartmentCollection departments = new DepartmentCollection();

            departments.Add("Sales", new Employee {
                Name = "Joy"
            })
            .Add("Sales", new Employee {
                Name = "Alex"
            })
            .Add("Sales", new Employee {
                Name = "Alex"
            });

            departments.Add("Engineering", new Employee {
                Name = "Scoot"
            })
            .Add("Engineering", new Employee {
                Name = "Alex"
            })
            .Add("Engineering", new Employee {
                Name = "Dani"
            });

            foreach (var department in departments)
            {
                Console.WriteLine(department.Key);
                foreach (var employee in department.Value)
                {
                    Console.WriteLine("\t" + employee.Name);
                }
            }
        }
Example #3
0
        static void Main(string[] args)
        {
            var departments = new DepartmentCollection();

            departments.Add("Sales", new Employee {
                Name = "John"
            })
            .Add("Sales", new Employee {
                Name = "Piter"
            });

            departments.Add("Engineering", new Employee {
                Name = "Sam"
            })
            .Add("Engineering", new Employee {
                Name = "Patrick"
            })
            .Add("Engineering", new Employee {
                Name = "Alex"
            })
            .Add("Engineering", new Employee {
                Name = "Alex"
            });

            foreach (var department in departments)
            {
                Console.WriteLine(department.Key);
                foreach (var employee in department.Value)
                {
                    Console.WriteLine("\t" + employee.Name);
                }
            }
            Console.ReadKey();
        }
Example #4
0
        static void Main(string[] args)
        {
            var departments = new DepartmentCollection();

            departments.Add("Sales", new Employee {
                Name = "Dani"
            })
            .Add("Sales", new Employee {
                Name = "Dani"
            })
            .Add("Sales", new Employee {
                Name = "Joy"
            });

            departments.Add("Engineering", new Employee {
                Name = "Dani"
            })
            .Add("Engineering", new Employee {
                Name = "Scott"
            })
            .Add("Engineering", new Employee {
                Name = "Alex"
            });



            foreach (var department in departments)
            {
                Console.WriteLine(department.Key);
                foreach (var employee in department.Value)
                {
                    Console.WriteLine("\t" + employee.Name);
                }
            }

            //var employeesByName = new SortedList<string, List<Employee>>();

            //employeesByName.Add("Sales", new List<Employee> { new Employee(), new Employee(), new Employee() });
            //employeesByName.Add("Engineering", new List<Employee> { new Employee(), new Employee() });

            //foreach (var item in employeesByName)
            //{
            //    Console.WriteLine("The count of employees for {0} is {1}",
            //                item.Key, item.Value.Count
            //            );
            //}
        }
        static void Main(string[] args)
        {
            var departements = new DepartmentCollection();

            //var departements = new SortedDictionary<string, SortedSet<Employee>>();
            //var departements = new SortedDictionary<string, HashSet<Employee>>();
            //var departements = new SortedDictionary<string, List<Employee>>();
            //var departements = new Dictionary<string, List<Employee>>();


            //departements.Add("Sales", new SortedSet<Employee>(new EmployeeComparer()));
            //departements["Sales"].Add(new Employee { Name = "Aly" });
            departements.Add("Sales", new Employee {
                Name = "Aly"
            })
            .Add("Sales", new Employee {
                Name = "Aly"
            })
            .Add("Sales", new Employee {
                Name = "Dani"
            });



            //departements.Add("Engineering", new SortedSet<Employee>(new EmployeeComparer()));
            departements.Add("Engineering", new Employee {
                Name = "Aly"
            })
            .Add("Engineering", new Employee {
                Name = "Aly"
            })
            .Add("Engineering", new Employee {
                Name = "Dani"
            });



            foreach (var departement in departements)
            {
                Console.WriteLine(departement.Key);
                foreach (var employee in departement.Value)
                {
                    Console.WriteLine("\t" + employee.Name);
                }
            }
        }
Example #6
0
        static void SortedAndClean()
        {
            //Prevent adding employees with same name to a department
            //and sort the employees within each department
            //+ remove all traces of generics from the business code (that's a good goal)

            var employeesByDepartment = new DepartmentCollection();

            employeesByDepartment.Add("Sales", new Employee {
                Name = "Joy"
            })
            .Add("Sales", new Employee {
                Name = "Deni"
            })
            .Add("Sales", new Employee {
                Name = "Deni"
            });

            employeesByDepartment.Add("Engineering", new Employee {
                Name = "Scott"
            })
            .Add("Engineering", new Employee {
                Name = "Alex"
            })
            .Add("Engineering", new Employee {
                Name = "Jovan"
            });

            foreach (var pair in employeesByDepartment)
            {
                Console.WriteLine("Department {0}", pair.Key);
                foreach (var employee in pair.Value)
                {
                    Console.WriteLine("\t{0}", employee.Name);
                }
            }

            Console.Read();
        }
Example #7
0
        static void Main(string[] args)
        {
            var departments = new DepartmentCollection();

            departments.Add("Sales", new Employee {
                Name = "Joy"
            })
            .Add("Sales", new Employee {
                Name = "Dani"
            })
            .Add("Sales", new Employee {
                Name = "Dani"
            });

            departments.Add("Engineering", new Employee {
                Name = "Scott"
            })
            .Add("Engineering", new Employee {
                Name = "Chris"
            })
            .Add("Engineering", new Employee {
                Name = "Alex"
            });

            foreach (var department in departments)
            {
                Console.WriteLine(department.Key);
                foreach (var employee in department.Value)
                {
                    Console.WriteLine("\t" + employee.Name);
                }
            }

            Utilities.LineBreak(3);

            // GenericCollections.RunGenericCollections();                  // Generic Collections: Testing

            Utilities.HaltProgramEnd();
        }