Beispiel #1
0
        // menu which asks for user input for hopping off the bus
        private void UserHopOffMenu(EzySystem ezySystem)
        {
            if (ezySystem.ThereIsPassengerOnBus())
            {
                Console.Write("Do you want to hop off passengers? (Y/N) ");
                string input = Console.ReadLine();

                while (String.Equals(input, "Y") || String.Equals(input, "y"))
                {
                    Console.WriteLine("Please select a bus stop from the list above.");
                    string busStopName = Console.ReadLine();
                    Console.WriteLine("The following are the buses which arrived at the chosen bus stop. Please select one.\n");
                    // display all buses in the bus stop
                    for (int i = 0; i < ezySystem.GetBusStopList().FindBusStopWithBusStopName(busStopName).GetBusQueueCount(); i++)
                    {
                        Console.WriteLine((i + 1) + ")" + ezySystem.GetBusStopList().FindBusStopWithBusStopName(busStopName).GetBusQueue()[i]);
                    }

                    string busName = Console.ReadLine();
                    Console.WriteLine("The following are the passengers inside this particular bus. Please select who will hop off.");
                    // display all passengers inside the bus // where to get the passenger
                    for (int i = 0; i < ezySystem.GetBusList().FindBusWithBusName(busName).GetPassengerList().Count; i++)
                    {
                        Console.WriteLine((i + 1) + ")" + ezySystem.FindUserWithMobileNumber(ezySystem.GetBusList().FindBusWithBusName(busName).GetPassengerList().ElementAt(i).GetMobileNum()));
                        //Console.WriteLine((i + 1) + ")" + ezySystem.GetUserList().FindUserWithMobileNumber((ezySystem.GetBusStopList().FindBusStopWithBusStopName(busStopName).GetPassengerList()[i].GetMobileNum())).GetName());
                    }

                    string userName = Console.ReadLine();
                    // remove passenger from the bus after this line
                    ezySystem.DequeueUserFromBus(userName, busName, busStopName);

                    // ask again if another passenger wants to hop off
                    Console.Write("\nDo you want to hop off passengers? (Y/N) ");
                    input = Console.ReadLine();
                }
            }
        }
        private void DisplayAllBusArrivals(EzySystem ezySystem)
        {
            // for each bus stop, check whether the bus queue has a bus which indicates that a bus has arrived
            for (int i = 0; i < ezySystem.GetBusStopList().GetCount(); i++)
            {
                // if there is at least one bus, display all bus arrivals
                if (ezySystem.GetBusStopList().At(i).GetBusQueueCount() > 0)
                {
                    for (int j = 0; j < ezySystem.GetBusStopList().At(i).GetBusQueueCount(); j++)
                    {
                        string busname = ezySystem.GetBusStopList().At(i).GetBusQueue().ElementAt(j), busstopname = ezySystem.GetBusStopList().At(i).GetName();

                        if (!ezySystem.BusNameIsInBusInterruptList1(busname, busstopname) && !ezySystem.BusStopIsInterrupted(busstopname))
                            DisplayBusArrival(ezySystem.GetBusStopList().At(i).GetName(), ezySystem.GetBusStopList().At(i).GetBusQueue().ElementAt(j));
                    }
                }
            }
        }
Beispiel #3
0
 // displays all of the bus arrivals
 private void DisplayAllBusArrivals(EzySystem ezySystem)
 {
     // for each bus stop, check whether the bus queue has a bus which indicates that a bus has arrived
     for (int i = 0; i < ezySystem.GetBusStopList().GetCount(); i++)
     {
         // if there is at least one bus, display all bus arrivals
         if (ezySystem.GetBusStopList().At(i).GetBusQueueCount() > 0)
         {
             for (int j = 0; j < ezySystem.GetBusStopList().At(i).GetBusQueueCount(); j++)
             {
                 DisplayBusArrival(ezySystem.GetBusStopList().At(i).GetName(), ezySystem.GetBusStopList().At(i).GetBusQueue().ElementAt(j));
             }
         }
     }
 }