Beispiel #1
0
        public void SwitchBetween(Employee emp1, Employee emp2)
        {
            Node <Employee> temp1 = emp1.GetNode(), temp2 = emp2.GetNode(), tempSub1 = emp1.GetSubordinates(), tempSub2 = emp2.GetSubordinates();

            emp1.SetSubordinates(null);
            emp2.SetSubordinates(null);
            temp1.SetValue(emp2);
            temp2.SetValue(emp1);
            emp1.SetSubordinates(tempSub2);
            emp2.SetSubordinates(tempSub1);
        }
Beispiel #2
0
        public static Company RandomComp(int depth, int numOfSubordinates)
        // Depth cant be positive if num of subordinates isnt positive...
        // The maximum amount of workers is: (subordinates ^ depth) - 1
        // There is a sub function here.
        {
            Company  comp = new Company("cmp", 0, null);
            Employee epic = new Employee("epic", -1, 0, comp);

            RandomSubordinates(depth, epic);
            comp.SetManagers(epic.GetSubordinates());
            return(comp);


            void RandomSubordinates(int low, Employee boss)
            {
                boss.SetSubordinates(new Node <Employee>(null));
                Node <Employee> p1 = boss.GetSubordinates();

                for (int i = rand.Next(1, numOfSubordinates + 1); i > 0; i--)
                {
                    double id = comp.GenerateID();
                    p1.SetValue(new Employee(id.ToString(), id, rand.Next(500, 1001) * (low + 1), comp));

                    if (rand.Next(low + 1) != 0)
                    {
                        RandomSubordinates(low - 1, p1.GetValue());
                    }

                    p1.SetNext(new Node <Employee>(null));
                    p1 = p1.GetNext();
                }

                p1 = boss.GetSubordinates();
                while (p1.GetNext().GetNext() != null)
                {
                    p1 = p1.GetNext();
                }
                p1.SetNext(null);
            }
        }
Beispiel #3
0
        public static Company CreateRandomCompany()
        {
            // 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" };

            Console.WriteLine("What would be the company's name?");
            string name = Console.ReadLine();

            Console.WriteLine("What would be its worth?");
            double worth = double.Parse(Console.ReadLine());

            Console.WriteLine("How many subordinates will a manager have?");
            int numOfSubordinates = int.Parse(Console.ReadLine());
            int depth             = 0;

            if (numOfSubordinates != 0)
            {
                Console.WriteLine("How low will the hierarchy go?");
                depth = int.Parse(Console.ReadLine());
            }
            Console.WriteLine("In what range will the lowest salary be? (num-num)");
            string[] temp = Console.ReadLine().Split('-');
            double   salary1 = double.Parse(temp[0]), salary2 = double.Parse(temp[1]);

            Company  comp = new Company(name, worth, null);
            Employee epic = new Employee("epic", -1, 0, comp);

            RandomSubordinates(depth, epic);
            comp.SetManagers(epic.GetSubordinates());

            Console.WriteLine(comp);
            return(comp);


            void RandomSubordinates(int low, Employee boss)
            {
                boss.SetSubordinates(new Node <Employee>(null));
                Node <Employee> p1 = boss.GetSubordinates();

                for (int i = rand.Next(1, numOfSubordinates + 1); i > 0; i--)
                {
                    double id = comp.GenerateID();
                    p1.SetValue(new Employee(names[rand.Next(names.Length)], id, rand.Next(Math.Min((int)salary1, (int)salary2), Math.Max((int)salary1, (int)salary2)) * (low + 1), comp));

                    if (rand.Next(low + 1) != 0)
                    {
                        RandomSubordinates(low - 1, p1.GetValue());
                    }

                    p1.SetNext(new Node <Employee>(null));
                    p1 = p1.GetNext();
                }

                p1 = boss.GetSubordinates();
                while (p1.GetNext().GetNext() != null)
                {
                    p1 = p1.GetNext();
                }
                p1.SetNext(null);
            }
        }