static void Main() { Configure(); Console.WriteLine("************ "); Console.WriteLine("This simple application calculates how many resupply stops are required to cover a given distance in mega lights (MGLT) for each avaiable StarShip "); Console.WriteLine("************ "); Console.Write("Input the distance in MGLT: "); if (long.TryParse(Console.ReadLine(), out long distanceMGLT)) { Console.WriteLine("Processing...\n"); foreach (var starship in _starshipService.GetStarshipsAsync().Result) { Console.WriteLine($"{starship.Name}: {starship.CalculateSupply(distanceMGLT)}"); } Console.WriteLine("\nDone.\nPress enter to close..."); } else { Console.WriteLine("\nInconsistent input MGLT..."); } Console.ReadLine(); }
public List <StarShipResupply> Get(long distanceMGLT) { var starShipsResupply = new List <StarShipResupply>(); foreach (var starship in _starshipService.GetStarshipsAsync().Result) { starShipsResupply.Add(new StarShipResupply(starship.Name, starship.CalculateSupply(distanceMGLT))); } return(starShipsResupply); }