public void AddGrains(Grains c)
 {           // + naujas iškrovimas
     if (n < Cmax)
     {
         GrainsArray[n++] = c;
     }
 }
 public void Sort()
 {           // rikiuojami iškrovimai
     for (int i = 0; i < n - 1; i++)
     {
         int minInd = i;
         for (int j = i + 1; j < n; j++)
         {
             if (GrainsArray[j].deliveryTime < GrainsArray[minInd].deliveryTime)
             {
                 minInd = j;
             }
         }
         Grains temp = GrainsArray[minInd];
         GrainsArray[minInd] = GrainsArray[i];
         GrainsArray[i]      = temp;
     }
 }
Ejemplo n.º 3
0
        static void ReadData(string file, GrainsContainer Warehouse)
        {               // nuskaito duomenis iš failo
            if (File.Exists(file))
            {
                using (StreamReader reader = new StreamReader(file))
                {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        string[] parts;
                        parts = line.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

                        string   name         = parts[0].Trim();
                        string   timeString   = parts[1];
                        TimeSpan deliveryTime = TimeSpan.Parse(timeString);
                        int      unloading    = int.Parse(parts[2]);
                        int      weight       = int.Parse(parts[3]);
                        Grains   newGrains    = new Grains(name, deliveryTime, unloading, weight);
                        Warehouse.AddGrains(newGrains);
                    }
                }
            }
        }