Пример #1
0
 public static Manager CreateManagerEmployeeTree()
 {
     Random rnd = new Random(4524); // Passing in a seed guarantees the same values each time
     Manager CEO = new Manager() { FirstName = fnames[rnd.Next(fnames.Length)], LastName = lnames[rnd.Next(lnames.Length)] };
     CreateReports(5, CEO, rnd);
     return CEO;
 }
Пример #2
0
 private static void CreateReports(int depth, Manager m, Random rnd)
 {
     int count = rnd.Next(10) + 3;
     for (int i = 0; i < count; i++)
     {
         int j = rnd.Next(10);
         IEmployee e = (j > 2 && depth > 1) ? (IEmployee)new Manager() : (IEmployee)new Employee();
         e.LastName = lnames[rnd.Next(lnames.Length)];
         e.FirstName = fnames[rnd.Next(fnames.Length)];
         e.DirectManager = m;
         m.ReportsList.Add(e);
         m.ReportsDict.Add(e.FirstName + i, e);
         if (e.IsManager) CreateReports(depth - 1, (Manager)e, rnd);
     }
 }
Пример #3
0
 public static Manager CreateManagerEmployeeTree()
 {
     Random rnd = new Random(4524);
     Manager CEO = new Manager() { FirstName = fnames[rnd.Next(fnames.Length)], LastName = lnames[rnd.Next(lnames.Length)] };
     CreateReports(5, CEO, rnd);
     return CEO;
 }