public static Department CreateDepartment(DepartmentNames name) { Department d = null; if (name == null) { return(null); } switch (name) { case DepartmentNames.SERVICE: d = new ServiceDepartment(); break; case DepartmentNames.SALES: d = new SalesDepartment(); break; case DepartmentNames.FINANCE: d = new FinanceDepartment(); break; default: break; } return(d); }
static void Main2302() { Console.WriteLine("Hello Visitor Pattern!"); EmployeeList empList = new EmployeeList(); IEmployee fteA = new FullTimeEmployee("0001", 3200.00, 45); IEmployee fteB = new FullTimeEmployee("0002", 2000, 40); IEmployee fteC = new FullTimeEmployee("0003", 2400, 38); IEmployee fteD = new PartTimeEmployee("0004", 80 * 40, 20); IEmployee fteE = new PartTimeEmployee("0005", 60 * 40, 18); empList.AddEmployee(fteA); empList.AddEmployee(fteB); empList.AddEmployee(fteC); empList.AddEmployee(fteD); empList.AddEmployee(fteE); var hr = new HRDepartment(); empList.Action(hr); Console.WriteLine("****************************************************"); var finance = new FinanceDepartment(); empList.Action(finance); Console.ReadLine(); }
public Company(Magnate founder) { this.founder = founder; currentOwner = founder; establishedDate = TimeManager.currentTime; boardOfDirectors = new AIPlayer(); boardOfDirectors.FirstName = "Board of Directors"; TimeManager.instance.OnDayEvent += DailyDepartmentWork; engineeringDepartment = new EngineeringDepartment(); facilitiesDepartment = new FacilitiesDepartment(); financeDepartment = new FinanceDepartment(); departments.Add(facilitiesDepartment); departments.Add(engineeringDepartment); departments.Add(financeDepartment); }