Esempio n. 1
0
 public Transport(int transport_seats_count, Station start_station)
 {
     seats_count = transport_seats_count;
     occupied_seats = 0;
     passengers = new SortedDictionary<Station, List<Passenger>>();
     current_station = start_station;
     traveled_distance = 0;
 }
Esempio n. 2
0
        public Passenger(uint time, Station station_from)
        {
            from = station_from;

            Random rand = new Random();
            int current_station = Array.FindIndex(Program.stations, (st) => st == station_from);
            int stations_count = Program.stations.Length;
            to = Program.stations[rand.Next(current_station + 1, stations_count - 1 + current_station) % stations_count];

            //Console.Write("Pasr comes at {0} to station {1}", time, from.name);
        }
Esempio n. 3
0
        public Passenger(uint time, Station station_from)
        {
            from = station_from;

            Random rand = new Random();
            int indexOfCurrentStation = Array.FindIndex(Program.stations, (st) => st == station_from);
            int indexOfLastStation = Program.stations.Length - 1;
            to = Program.stations[rand.Next(0, indexOfLastStation)];

            Console.Write("Time {0} | Station {1} | Passengers ", time, from.name);
        }
Esempio n. 4
0
        public void RunTransportOnArrival(uint time)
        {
            TransportComing();
            uint time_to_next_station = current_station.time_to_next_station;
            //Console.WriteLine("Transport coming to station {0} time to next st {1}, free seats = {2}",
            //    current_station.name,current_station.time_to_next_station, seats_count - occupied_seats);
            traveled_distance += time;
            if (traveled_distance > Program.distance)
            {
                traveled_distance -= Program.distance;
            }

            current_station = current_station.next_station;
            Program.event_queue1.Add(time + time_to_next_station, this.RunTransportOnArrival);
        }
Esempio n. 5
0
 public void AddNextStation(Station next_station_)
 {
     next_station = next_station_;
 }