Ejemplo n.º 1
0
        public int Move(int rank)
        {
            BusRoute currentRoute = BusSystem.GetBusRoute(RouteId);

            int currentStopId    = currentRoute.GetBusStopInfoByBusLocation(Location).Item2;
            var resut            = currentRoute.GetBusStopInfoByBusLocation(Location + 1);
            int nextStopId       = resut.Item2;
            int nextStopLocation = resut.Item1;

            BusStop currentStop = BusSystem.GetBusStop(currentStopId);
            BusStop nextStop    = BusSystem.GetBusStop(nextStopId);

            //Bus left current stop
            // int offBus = BusRider.GetRiderOffBus(nextStopId, rank);
            // int onBus = BusRider.GetRiderOnBus(nextStopId, rank);

            //UpdateBusPassenger(offBus, onBus);
            UpdateBusLocation(nextStopLocation);
            //nextStop.UpdateStopRidersByBus(onBus, offBus);

            int time = BusStop.CalculateTimeWithSpeed(currentStop, nextStop, Speed);

            Console.WriteLine("b:{0}->s:{1}@{2}//p:{3}/f:{4}", Id, nextStopId, time + rank, 0, 0);
            return(time);
        }
Ejemplo n.º 2
0
        public static void CreateObject(List <string> command)
        {
            switch (command[0])
            {
            case "add_depot":
//                    BusStop busStop0 = new BusStop(Convert.ToInt32(command[1]), command[2],0, Convert.ToDouble(command[3]), Convert.ToDouble(command[4]));
//                    BusStops.Add(busStop0);
                break;

            case "add_bus":
                Bus bus1 = new Bus(Convert.ToInt32(command[1]), Convert.ToInt32(command[2]), Convert.ToInt32(command[3]), Convert.ToInt32(command[4]), Convert.ToInt32(command[5]),
                                   Convert.ToInt32(command[6]), Convert.ToInt32(command[7]), Convert.ToInt32(command[8]));
                Buses.Add(bus1);
                break;

            case "add_stop":
                BusStop busStop1 = new BusStop(Convert.ToInt32(command[1]), command[2], Convert.ToInt32(command[3]), Convert.ToDouble(command[4]), Convert.ToDouble(command[5]));
                BusStops.Add(busStop1);
                break;

            case "add_route":
                BusRoute busRoute1 = new BusRoute(Convert.ToInt32(command[1]), Convert.ToInt32(command[2]), command[3]);
                BusRoutes.Add(busRoute1);
                break;

            case "extend_route":
                BusRoute targetRoute = GetBusRoute(Convert.ToInt32(command[1]));
                targetRoute?.ExtendRoute(Convert.ToInt32(command[2]));
                break;

            case "add_event":
                SimEvent simEvent = new SimEvent(Convert.ToInt32(command[1]), command[2], Convert.ToInt32(command[3]));
                SimEventQueue.AddSimEventsQueue(simEvent);
                break;

            default:
                break;
            }
        }