/// <summary> /// The method creates an instance of the client's handler class /// and initializes the employee structure. /// After then it calls handler class methods of commands /// entered by client. /// After each iteration of the loop do-while, /// user is asked to press a key Escape /// or continue working with application /// by pressing any other key. /// </summary> /// <param name="args"></param> static void Main(string[] args) { try { Console.WriteLine(Welcome); StaffSelectionConsoleHandler consoleHandler = new StaffSelectionConsoleHandler(); Staffs staffs = new Staffs( new Junior(JuniorSalary, JuniorProductivity), new Middle(MiddleSalary, MiddleProductivity), new Senior(SeniorSalary, SeniorProductivity), new Lead(LeadSalary, LeadProductivity)); do { // called method for input // current amount and required productivity of the client StaffSelector currentSelector = consoleHandler.PackingClientPersonalData(); currentSelector.Staffs = staffs; // called method for choice desired criteria consoleHandler.SelectCriterion(currentSelector); // choice of employees according to the entered parameters List <Dictionary <FellowWorker, int> > result = currentSelector.SelectTeams(); // print results consoleHandler.PrintTeams(result); Console.WriteLine(Choice); } while (Console.ReadKey(true).Key != ConsoleKey.Escape); } catch (Exception exc) { Console.WriteLine(exc.Message); } }
/// <summary> /// Method helps to organize solution into the team of employees /// like "Staff" - "Count" /// </summary> /// <param name="decisions">required solution of the optimization problem</param> /// <param name="staffs">current staffs in company</param> /// <returns></returns> protected Dictionary <FellowWorker, int> PackSolutionInDictionary(Decision[] decisions, Staffs staffs) { Dictionary <FellowWorker, int> result = new Dictionary <FellowWorker, int>(); int i = 0; foreach (var decision in decisions) { result.Add(staffs.StaffsArray[i++], (int)decision.GetDouble()); } return(result); }