Exemplo n.º 1
0
 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;
     }
 }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
 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--;
     }
 }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
 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?
 }
Exemplo n.º 6
0
 private static double GetPrisonTime(Thief thief)
 {
     return((DateTime.Now - thief.TimeOfCapture).TotalSeconds);
 }
Exemplo n.º 7
0
 private static void SendToPrison(Thief thief, List <Thief> prison)
 {
     thief.TimeOfCapture = DateTime.Now;
     prison.Add(thief);
     thief.IsInPrison = true;
 }