public void FertilizeData() { string robotId; string landId; bool validate; int countRobots = 0; Console.WriteLine("List of lands:"); LandList.ForEach(l => { Console.WriteLine($"ID: {l.Id} | Fertility: {l.Fertility}%"); }); Console.WriteLine("Available robots:"); RobotList.ForEach(r => { if (r.Activated) { Console.WriteLine($"ID:{r.Id} | Battery: {r.Battery}/{r.MaxBattery}"); } countRobots++; }); if (countRobots > 0) { Console.Write("Enter the land id: "); landId = Console.ReadLine(); StringValidate.Value = landId; validate = StringValidate.ValidateField(); Console.Write("Enter the robot id: "); robotId = Console.ReadLine(); StringValidate.Value = robotId; validate = validate && StringValidate.ValidateField(); if (validate) { Land l = LandList.FirstOrDefault(p => p.Id == landId); Robot r = RobotList.FirstOrDefault(c => c.Id == robotId && c.Activated); if (l != null) { Handler.Fertilize(l); } else { Console.WriteLine("No available lands match the entered id"); } } else { Console.WriteLine("The data input was invalid"); } } else { Console.WriteLine("No available robots"); } }
public void RobotData(string option) { string id; bool validate; string state; Console.WriteLine("List of robots:"); RobotList.ForEach(r => { state = (r.Activated) ? "on" : "off"; Console.Write($"ID:{r.Id} | Battery: {r.Battery}/{r.MaxBattery} | "); Console.WriteLine($"State: {state}"); }); Console.Write("Enter the robot id: "); id = Console.ReadLine(); StringValidate.Value = id; validate = StringValidate.ValidateField(); if (validate) { Robot r = RobotList.FirstOrDefault(c => c.Id == id); if (r != null) { if (option == "3") { Handler.Upgrade(r); } else if (option == "4") { Handler.ChargeRobot(r); } else if (option == "5") { Handler.OnOffRobot(r); } } else { Console.WriteLine("No robots match the entered id"); } } else { Console.WriteLine("The data input was invalid"); } }
public void HaverstData() { string landId; string robotId; bool validate; int countRobots = 0; int countCrops = 0; Console.WriteLine("Lands with crops ready to harvest:"); LandList.ForEach(l => { if (l.Used && l.LandCrop.Growth == 100) { Console.Write($"ID: {l.Id} | Crop: {l.LandCrop.Type} | "); Console.WriteLine($"Edibility {l.LandCrop.Edibility}%"); countCrops++; } }); if (countCrops > 0) { Console.WriteLine("Available robots:"); RobotList.ForEach(r => { if (r.Activated) { Console.WriteLine($"ID:{r.Id} | Battery: {r.Battery}/{r.MaxBattery}"); } countRobots++; }); if (countRobots > 0) { Console.Write("Enter the land id: "); landId = Console.ReadLine(); StringValidate.Value = landId; validate = StringValidate.ValidateField(); Console.Write("Enter the robot id: "); robotId = Console.ReadLine(); StringValidate.Value = robotId; validate = validate && StringValidate.ValidateField(); if (validate) { Land l = LandList.FirstOrDefault(c => c.Id == landId && c.Used && c.LandCrop.Growth == 100); Robot r = RobotList.FirstOrDefault(c => c.Id == robotId && c.Activated); if (l != null && r != null) { Handler.Harvest(l); } else { Console.WriteLine("No robots or lands match the entered id"); } } else { Console.WriteLine("The data input was invalid"); } } else { Console.WriteLine("No available robots"); } } else { Console.WriteLine("No current crops"); } }
public void AsignData() { string landId; string robotId; bool validate; int countRobots = 0; int countEvents = 0; Console.WriteLine("Lands with active events:"); LandList.ForEach(l => { if (l.Used && l.LandCrop.EventBool) { Console.WriteLine($"ID: {l.Id} | Event: {l.LandCrop.CurrentEvent.Name}"); countEvents++; } }); if (countEvents > 0) { Console.WriteLine("Available robots:"); RobotList.ForEach(r => { if (r.Activated) { Console.WriteLine($"ID:{r.Id} | Battery: {r.Battery}/{r.MaxBattery}"); } countRobots++; }); if (countRobots > 0) { Console.Write("Enter the land id: "); landId = Console.ReadLine(); StringValidate.Value = landId; validate = StringValidate.ValidateField(); Console.Write("Enter the robot id: "); robotId = Console.ReadLine(); StringValidate.Value = robotId; validate = validate && StringValidate.ValidateField(); if (validate) { Land l = LandList.FirstOrDefault(c => c.Id == landId && c.Used && c.LandCrop.EventBool); Robot r = RobotList.FirstOrDefault(c => c.Id == robotId && c.Activated); if (l != null && r != null) { Handler.ClearEvent(l); } else { Console.WriteLine("No robots or lands match the entered id"); } } else { Console.WriteLine("The data input was invalid"); } } else { Console.WriteLine("No available robots"); } } else { Console.WriteLine("No current events"); } }