//********nanny******* /// <summary> /// this function implements adding nanny to the list of nannies /// </summary> /// <param name="nanny">nanny to add</param> public void addNanny(Nanny nanny) { if (DateTime.Compare(DateTime.Now.AddYears(-18), nanny.date_of_birth) < 0) { throw new Exception("מטפלת זו צעירה מידי"); } if (nanny.max_age <= nanny.min_age) { throw new Exception("...לא נבחר טווח גילאים נכון"); } if (nanny.max_of_children == 0) { throw new Exception("...לא נבחרה כמות מקסימלית של ילדים"); } bool flag = true; for (int i = 0; i < 6; i++) { if (nanny.get_workdays(i) == true) { flag = false; } } if (flag) { throw new Exception("לא נבחרו ימי טיפול"); } mydal.addNanny(nanny); }
/// <summary> /// a fanc that compares the times of a nanny with times of mother /// </summary> /// <param name="nanny">this specific nanny would be checked</param> /// <param name="mother">this specific mother would be checked</param> /// <returns></returns> static bool Working_times(Nanny nanny, Mother mother) { bool flag = true; for (int i = 0; i < 6; i++) { if (mother.get_workdays(i) == true && nanny.get_workdays(i) == false) { flag = false; break; } if (mother.get_workdays(i) == true && nanny.get_workdays(i) == true) { if (mother.get_workhours_start(i) < nanny.get_workhours_start(i) || nanny.get_workhours_end(i) < mother.get_workhours_end(i)) { flag = false; } } break; } return(flag); }
/// <summary> /// checking matching between mother and nanny /// </summary> /// <param name="nanny">this specific nanny would be checked</param> /// <param name="mother">this specific mother would be checked</param> /// <returns></returns> static bool matching(Nanny nanny, Mother mother) { bool flag = false; for (int i = 0; i < 6; i++) { flag = false; if (mother.get_workdays(i) == true && nanny.get_workdays(i) == false) { flag = false; break; } else { if (mother.get_workhours_start(i) >= nanny.get_workhours_start(i) && mother.get_workhours_end(i) <= nanny.get_workhours_end(i)) { flag = true; } } } return(flag); }