public bool PlaceTram(Tram newTram)
 {
     foreach (Track track in TestData.Tracks)
     {
         if (track.AssignTramToSector(newTram))
         {
             return(true);
         }
     }
     return(false);
 }
        public bool PlaceTramRandomSector(Tram newTram)
        {
            Random rnd      = new Random();
            int    rndTrack = rnd.Next(TestData.Tracks.Count);

            if (TestData.Tracks[rndTrack].AssignTramToRandomSector(newTram))
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 3
0
 public bool TryAddTram(Tram tram)
 {
     if (_tramList.Count == 0)
     {
         _tramList.Add(tram);
         return(true);
     }
     else
     {
         return(false);
     }
 }
        public bool AssignTramToSector(Tram tram)
        {
            for (int x = 0; x < Sectors.Length; x++)
            {
                if (Sectors[x].TryAddTram(tram))
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 5
0
        public static Tram GetRandomTram()
        {
            Random rnd        = new Random();
            int    rnd1       = rnd.Next(possibleTramNumbers.Length);
            int    rnd2       = rnd.Next(possibleTramTypes.Length);
            int    rnd3       = rnd.Next(possibleStatusses.Length);
            Tram   returnTram = new Tram(possibleTramNumbers[rnd1], possibleTramTypes[rnd2]);

            returnTram.Status = possibleStatusses[rnd3];

            return(returnTram);
        }
        public Tram GetTram(string tramNumber)
        {
            foreach (Track track in TestData.Tracks)
            {
                Tram tram = track.GetTram(tramNumber);
                if (tram != null)
                {
                    return(tram);
                }
            }

            return(null);
        }
        public Tram GetTram(string tramNumber)
        {
            foreach (Sector sector in Sectors)
            {
                Tram tram = sector.GetTram(tramNumber);
                if (tram != null)
                {
                    return(tram);
                }
            }

            return(null);
        }
        public bool AssignTramToRandomSector(Tram tram)
        {
            Random rnd       = new Random();
            int    rndSector = rnd.Next(Sectors.Length);

            if (Sectors[rndSector].TryAddTram(tram))
            {
                return(true);
            }
            else
            {
                return(AssignTramToSector(tram));
            }
        }
Ejemplo n.º 9
0
 public void RemoveTram(Tram tram)
 {
     Trams.Remove(tram);
 }