public override bool IsTherePLaceForBoatInHarbour() { int halfPlaceSpot = FreeWharfSpace.WhereIsHalfPlace(); if (halfPlaceSpot > 0) { return(true); } else { List <FreeWharfSpace> list = FreeWharfSpace.ListOfFreeWharfPlacesInHarbour(); var l1 = list .Where(l => l.LenghtOfFreePlaces >= NumberOfWharfPlacesNeededAtHarbour) .ToList(); return(l1.Count() > 0); } }
public override int CheckForBestPlaceInHarbour() { int halfPlaceSpot = FreeWharfSpace.WhereIsHalfPlace(); if (halfPlaceSpot > 0) { return(halfPlaceSpot); } else { List <FreeWharfSpace> list = FreeWharfSpace.ListOfFreeWharfPlacesInHarbour(); var q1 = list .Where(q => q.LenghtOfFreePlaces >= NumberOfWharfPlacesNeededAtHarbour) .OrderBy(q => (q.LenghtOfFreePlaces > NumberOfWharfPlacesNeededAtHarbour + 4 ? NumberOfWharfPlacesNeededAtHarbour + 5 : q.LenghtOfFreePlaces) + AsCloseSameDaysLeftInHarbour(q)) .Select(q => StartOrEndPosition(q)) .ToList(); return(q1[0]); } }
public static List <string> StringInfo() { List <string> info = new List <String>(); info.Add($"DAG {Counter.DaysSinceStartOfSimulation}. Idag kom det {Counter.NumberOfNewBoatsPerUdate} nya båtar till hamnen.\n"); info.Add($"I hamnen ligger nu:\n- Roddbåtar \t{Counter.GetNumberOfBoatType("R")} st\n- Motorbåtar \t{Counter.GetNumberOfBoatType("M")} st\n- Segelbåtar \t{Counter.GetNumberOfBoatType("S")} st\n- Katamaraner \t{Counter.GetNumberOfBoatType("K")} st\n- Lastfartyg \t{Counter.GetNumberOfBoatType("L")} st\n"); info.Add($"Summan av alla båtars vikt: {Counter.TotalWeight()} kg.\n"); info.Add($"Medelhastighet för alla båtar: {Counter.AverageKmPerHour()} km/h.\n"); info.Add($"Antal hela lediga platser: {Counter.GetNumberOfFreeSpots()} st\nAntal lediga halvplatser (för roddbåt): {(FreeWharfSpace.WhereIsHalfPlace() > 0 ? "1" : "0")} st.\n"); info.Add($"Antal avvisade båtar för dagen: {Counter.NumberOfDeclinedBoatsEachDay} st\n"); info.Add($"Antal avvisade båtar sedan simuleringens start: {Counter.NumberOfDeclinedBoatsSinceStartOfSimulation} st\nAvvisade båtar i genomsnitt per år: {Counter.DeclinedBoatsPerYear()} st/år.\n"); if (Counter.NumberOfDeclinedBoatsEachDay > 0) { string s = "Avvisade båtar: "; foreach (var boat in HarbourAdministration.DeclinedBoats) { s += $"{boat.IdentityNumber} "; } info.Add(s); } return(info); }