private static void ConfiscateSwag(Thief thief, Police police) { for (int i = 0; i < thief.Swag.Count; i++) { police.ConfiscatedItems[i].NoOfItems += thief.Swag[i].NoOfItems; thief.Swag[i].NoOfItems = 0; } }
public static string PrintThief(Thief t) { string s = $"xdir: {t.XDirection}, ydir: {t.YDirection}, " + $"xpos: {t.XPosition}, ypos: {t.YPosition}, "; for (int i = 0; i < t.Swag.Count; i++) { s += $"{t.Swag[i]}, "; } return(s); }
private static void PerformTheft(Citizen citizen, Thief thief) { if (CheckBelongings(citizen)) { int selectedItem = r.Next(0, citizen.Belongings.Count); while (citizen.Belongings[selectedItem].NoOfItems < 1) { selectedItem = r.Next(0, citizen.Belongings.Count); } thief.Swag[selectedItem].NoOfItems++; citizen.Belongings[selectedItem].NoOfItems--; } }
private static bool CheckSwag(Thief thief) { bool hasSwag = false; for (int i = 0; i < 4; i++) { if (thief.Swag[i].NoOfItems > 0) { hasSwag = true; break; } } return(hasSwag); }
private static void SendToFreedom(Thief thief, List <Thief> prison) { prison.Remove(thief); thief.IsInPrison = false; // Samma tjuv som jag skickade hit genom prison-listan finns väl även i Thief-listan ? dvs båda listorna pekar på samma tjuv? }
private static double GetPrisonTime(Thief thief) { return((DateTime.Now - thief.TimeOfCapture).TotalSeconds); }
private static void SendToPrison(Thief thief, List <Thief> prison) { thief.TimeOfCapture = DateTime.Now; prison.Add(thief); thief.IsInPrison = true; }