Beispiel #1
0
        public static void Hire(Company comp)
        {
            // A list of possible names
            string[] names = new string[] { "Aiden Fuller", "Mikolaj Maldonado", "Nichola Correa", "Jobe Kemp", "Finnian Cano", "Dawn Clements", "Giovanni Craft", "Charity Keenan", "Evie-Rose Potts", "Maxim Delgado", "Luis Ware", "Aleksander Bowers", "Ameena Velazquez", "Rylan Regan", "Riaz Cook", "Keenan Conroy", "Suzanne Mcdermott", "Kyron Odonnell", "Dotty Hensley", "Kamile Knights", "Konrad Bloggs", "Orlando Sheehan", "Moses Davenport", "Nimrah Anthony", "Milton Dean", "Tamara Wills", "Hywel Clay", "Andreea Quinn", "Abdi Watson", "Abdur Rose", "Elysia Peacock", "Ammara Flynn", "June Gilmour", "Brittany Coffey", "Marwah Mccullough", "Adam Donald", "Cheryl Hodge", "Oakley Martins", "Marshall Hess", "Aleisha Childs", "Marcus Davidson", "Oluwatobiloba Hawkins", "Indigo Swift", "Yasser Ventura", "Osama Guevara", "Domonic Cameron", "Amanda Hoover", "Lexie Jacobson", "Buddy Davies", "Shyam John", "Wilf Rudd", "Keane Hickman", "Greg Petersen", "Francisco Adamson", "Uzma Williams", "Leila Millar", "Garin Day", "Alara Noble", "Sebastian East", "Russell Gay", "Humzah Cooke", "Amy Hansen", "Kimberley Bouvet", "Zander Vaughan", "Lulu Wilde", "Zacharia Paine", "Aurelia Dunkley", "Niko Simon", "Haydon Carey", "James Norton", "Christopher Townsend", "Nigel Hooper", "Elaine Fraser", "Daisie Harding", "Ihsan Frederick", "Rimsha Barrett", "Cassie Bone", "Massimo Allen", "Lynn Andrew", "Conah Perez", "Viktor Couch", "Shawn Downs", "Kali Kay", "Clarke Vo", "Kayla Sparrow", "Darcie Atkinson", "Eryn Davila", "Azaan Garza", "Sunil Callaghan", "Layton Mcneill", "Farhana Feeney", "Myles Kirk", "Maksymilian Carroll", "Elisha Melia", "Aizah Lake", "Gracie-Mae Galloway", "Kaiser Randolph", "Josh Mueller", "Kasper Woodard", "Said Power" };

            // printing the names to choose from and organizing
            Console.WriteLine("You posted a hiring poster and these want to be hired:");
            Console.WriteLine();
            int exp;

            string[] noticed = new string[rand.Next(2, 6)];
            for (int i = 0; i < noticed.Length; i++)
            {
                noticed[i] = names[rand.Next(names.Length)];
                exp        = rand.Next(7);

                Console.WriteLine("Name: {0} \nExperience: {1} years \n", noticed[i], exp);
            }

            // choosing the employee
            Console.WriteLine("Which one do you want to choose? (index)");
            int ind = int.Parse(Console.ReadLine());

            Console.WriteLine("And in which group would you like to put him/her? (0 - {0})", comp.GetLowestEmployees().GetValue().BossCount() + 1);
            Console.WriteLine("0 - Manager");
            Console.WriteLine("{0} - Subordinate of a rookie", comp.GetLowestEmployees().GetValue().BossCount() + 1);
            int position = int.Parse(Console.ReadLine());

            Console.WriteLine("What would be his/her salary?");
            double   salary = double.Parse(Console.ReadLine());
            Employee newOne = new Employee(noticed[ind], comp.GenerateID(), salary, comp);



            if (position == 0)
            {
                comp.GetManagers().GetLast().SetNext(new Node <Employee>(newOne));
            }
            else
            {
                Node <Employee>      possibleBosses = new Node <Employee>(null);
                Del <object, object> okBoss         = delegate(object nothing, Employee emp1)
                {
                    if (position - 1 == emp1.BossCount())
                    {
                        possibleBosses.GetLast().SetNext(new Node <Employee>(emp1));
                    }
                    return(null);
                };
                comp.ForEveryEmployee <object, object>(okBoss);
                possibleBosses = possibleBosses.GetNext();

                possibleBosses.GetNext(rand.Next(possibleBosses.GetLength())).GetValue().AddSubordinate(new Node <Employee>(newOne));
            }
        }
Beispiel #2
0
        public Node <Employee> GetLowestEmployees()
        {
            Node <Employee>      lowestEmp      = null;
            int                  maxNumOfBosses = -1;
            Del <object, object> updLowest      = delegate(object nothing, Employee emp1)
            {
                int bosss = emp1.BossCount();

                if (bosss == maxNumOfBosses)
                {
                    lowestEmp.GetLast().SetNext(new Node <Employee>(emp1));
                    return(null);
                }
                if (bosss > maxNumOfBosses)
                {
                    maxNumOfBosses = bosss;
                    lowestEmp      = new Node <Employee>(emp1);
                }
                return(null);
            };

            ForEveryEmployee <object, object>(updLowest);
            return(lowestEmp);
        }