/// <summary> /// Calculate the amount of stops based on Hours Consumables, MGLT and Distance (user input) /// </summary> public async Task <int> CalculateAmountOfStopsAsync(Starship starship, decimal distance) { try { int hours = await starship.GetHoursConsumablesAsync(); if (hours > 0 && Int32.TryParse(starship.MGLT.Trim(), out int mglt)) { // The (int) makes the number round down. return(await Task.FromResult((int)(distance / (hours * mglt)))); } return(await Task.FromResult(0)); } catch (Exception) { throw; } }