protected bool ApproveVacation(VacationRequest request) { int daysOff = request.GetNumberOfDaysOff(); if (daysOff <= GetMaxVacationDaysCanAprove()) { Console.WriteLine("It's ok! " + this.GetType()); return(true); } return(false); }
public void ApplyVacationRequest(VacationRequest request) { if (Supervisor != null) { if (Supervisor.ApproveVacation(request)) { return; } Supervisor.ApplyVacationRequest(request); } else { Console.WriteLine("HR approval needed."); } }
static void Main(string[] args) { Employee employee1 = new Employee(new TeamLeader(new ProjectLeader(new DepartmentDirector(null)))); VacationRequest request1 = new VacationRequest(new DateTime(2019, 10, 25), new DateTime(2019, 10, 30)); employee1.ApplyVacationRequest(request1); Employee employee2 = new Employee(new TeamLeader(new ProjectLeader(new DepartmentDirector(null)))); VacationRequest request2 = new VacationRequest(new DateTime(2019, 10, 21), new DateTime(2019, 10, 30)); employee2.ApplyVacationRequest(request2); Employee employee3 = new Employee(new TeamLeader(new ProjectLeader(new DepartmentDirector(null)))); VacationRequest request3 = new VacationRequest(new DateTime(2019, 10, 16), new DateTime(2019, 10, 30)); employee3.ApplyVacationRequest(request3); Employee employee4 = new Employee(new TeamLeader(new ProjectLeader(new DepartmentDirector(null)))); VacationRequest request4 = new VacationRequest(new DateTime(2019, 10, 10), new DateTime(2019, 10, 30)); employee4.ApplyVacationRequest(request4); }