Exemplo n.º 1
0
        public void AddGeneratedItem()
        {
            this.Size += 1;
            bool ok = false;

            do
            {
                SteamBoat steamBoat = new SteamBoat(ShipName[random.Next(0, ShipName.Length)] + ShipNamePostfix[random.Next(0, ShipNamePostfix.Length)], random.Next(1950, 2020), random.Next(50, 140), random.Next(10, 100), PortName[random.Next(0, PortName.Length)], random.Next(800, 1600));
                if (!(this.SortedDictionaryShip.ContainsKey(steamBoat.GetBaseShip)))
                {
                    this.SortedDictionaryShip.Add(steamBoat.GetBaseShip, steamBoat);
                    this.QueueShip.Enqueue(steamBoat.GetBaseShip);
                    this.StringSortedDictionaryShip.Add(steamBoat.GetBaseShip.ToString(), steamBoat);
                    this.StringQueueShip.Enqueue(steamBoat.GetBaseShip.ToString());
                    ok = true;
                }
            } while (!ok);
        }
Exemplo n.º 2
0
 public void GenerateEverething()
 {
     this.QueueShip                  = new Queue <Ship>();
     this.StringQueueShip            = new Queue <string>();
     this.SortedDictionaryShip       = new SortedDictionary <Ship, SteamBoat>();
     this.StringSortedDictionaryShip = new SortedDictionary <string, SteamBoat>();
     for (int i = 0; i < Size; i++)
     {
         bool ok = false;
         do
         {
             SteamBoat steamBoat = new SteamBoat(ShipName[random.Next(0, ShipName.Length)] + ShipNamePostfix[random.Next(0, ShipNamePostfix.Length)], random.Next(1950, 2020), random.Next(50, 140), random.Next(10, 100), PortName[random.Next(0, PortName.Length)], random.Next(800, 1600));
             if (!(this.SortedDictionaryShip.ContainsKey(steamBoat.GetBaseShip)))
             {
                 this.SortedDictionaryShip.Add(steamBoat.GetBaseShip, steamBoat);
                 this.QueueShip.Enqueue(steamBoat.GetBaseShip);
                 this.StringSortedDictionaryShip.Add(steamBoat.GetBaseShip.ToString(), steamBoat);
                 this.StringQueueShip.Enqueue(steamBoat.GetBaseShip.ToString());
                 ok = true;
             }
         } while (!ok);
     }
 }