static void Main()
        {
            List <Employee> empArray = new List <Employee>();

            // generate random numbers for
            // both the integers and the
            // employee id's
            Random r = new Random();

            // populate the array
            for (int i = 0; i < 5; i++)
            {
                // add a random employee id

                empArray.Add(
                    new Employee(
                        r.Next(10) + 100, r.Next(20)

                        )
                    );
            }

            // display all the contents of the Employee array
            for (int i = 0; i < empArray.Count; i++)
            {
                Console.Write("\n{0} ", empArray[i].ToString());
            }
            Console.WriteLine("\n");


            // sort and display the employee array
            Employee.EmployeeComparer c = Employee.GetComparer();
            c.WhichComparison = Employee.EmployeeComparer.ComparisonType.EmpID;
            empArray.Sort(c);

            // display all the contents of the Employee array
            for (int i = 0; i < empArray.Count; i++)
            {
                Console.Write("\n{0} ", empArray[i].ToString());
            }
            Console.WriteLine("\n");


            c.WhichComparison = Employee.EmployeeComparer.ComparisonType.YearsOfService;
            empArray.Sort(c);

            for (int i = 0; i < empArray.Count; i++)
            {
                Console.Write("\n{0} ", empArray[i].ToString());
            }
            Console.WriteLine("\n");
        }
Beispiel #2
0
        static void Main()
        {
            List <Employee> empArray = new List <Employee>();

            //generira slucajne brojeve za cijelobrojne vrijednosti
            //i identifikatore zaposlenika
            Random r = new Random();

            //popunjava polje
            for (int i = 0; i < 5; i++)
            {
                empArray.Add(new Employee(r.Next(10) + 100, r.Next(20)));
            }

            //prikazuje sad sadrzaj polja Employee
            for (int i = 0; i < empArray.Count; i++)
            {
                Console.Write("\n{0} ", empArray[i].ToString());
            }
            Console.WriteLine("\n");

            Employee.EmployeeComparer c = Employee.GetComparer();
            c.WhichComparasion = Employee.EmployeeComparer.ComparasionType.EmpID;
            empArray.Sort(c);

            //prikazuje sav sadrzaj Employee
            for (int i = 0; i < empArray.Count; i++)
            {
                Console.Write("\n{0} ", empArray[i].ToString());
            }
            Console.WriteLine("\n");

            c.WhichComparasion = Employee.EmployeeComparer.ComparasionType.Yrs;
            empArray.Sort(c);

            for (int i = 0; i < empArray.Count; i++)
            {
                Console.Write("\n{0} ", empArray[i].ToString());
            }
            Console.WriteLine("\n");
        }
Beispiel #3
0
        static void Main()
        {
            List <Employee> empArray = new List <Employee>();

            Random r = new Random();

            for (int i = 0; i < 5; i++)
            {
                empArray.Add(new Employee(r.Next(10) + 100, r.Next(20)));
            }

            for (int i = 0; i < empArray.Count; i++)
            {
                Console.Write("\n{0} ", empArray[i].ToString());
            }
            Console.WriteLine("\n");

            Employee.EmployeeComparer c = Employee.GetComparer();
            c.whichComparison = Employee.EmployeeComparer.ComparisonType.EmpID;
            empArray.Sort(c);

            for (int i = 0; i < empArray.Count; i++)
            {
                Console.Write("\n{0} ", empArray[i].ToString());
            }
            Console.WriteLine("\n");

            c.whichComparison = Employee.EmployeeComparer.ComparisonType.Yrs;
            empArray.Sort(c);

            for (int i = 0; i < empArray.Count; i++)
            {
                Console.Write("\n{0} ", empArray[i].ToString());
            }
            Console.WriteLine("\n");
        }