public string HirePilot(string name) { if (PilotsList.Exists(x => x.Name == name)) { return(String.Format(OutputMessages.PilotExists, name)); } else { IPilot pilot = new Pilot(name); PilotsList.Add(pilot); return(String.Format(OutputMessages.PilotHired, name)); } }
public string EngageMachine(string selectedPilotName, string selectedMachineName) { if (!PilotsList.Exists(x => x.Name == selectedPilotName)) { return(String.Format(OutputMessages.PilotNotFound, selectedPilotName)); } if (!MachineList.Exists(x => x.Name == selectedMachineName)) { return(String.Format(OutputMessages.MachineNotFound, selectedMachineName)); } var index = MachineList.FindIndex(x => x.Name == selectedMachineName); if (machineList[index].Pilot != null) { return(String.Format(OutputMessages.MachineHasPilotAlready, selectedMachineName)); } else { var indexPilot = PilotsList.FindIndex(x => x.Name == selectedPilotName); machineList[index].Pilot = PilotsList[indexPilot]; return(String.Format(OutputMessages.MachineEngaged, selectedPilotName, selectedMachineName)); } }