Esempio n. 1
0
    public static void NewPlane(planeAction action)
    {
        plane newPlane = new plane();

        newPlane.ID      = planesProcesed;
        newPlane.airline = airlineName();

        if (action == planeAction.arrive)
        {
            newPlane.ID = landingID;
            landingID  += 2;
        }
        else if (action == planeAction.depart)
        {
            newPlane.ID = takeOffID;
            takeOffID  += 2;
        }

        bool refused = checkRefuse(newPlane, action);

        if (!refused && action == planeAction.arrive)
        {
            landingQ.Enqueue(newPlane);
        }
        else if (!refused && action == planeAction.depart)
        {
            takeOffQ.Enqueue(newPlane);
        }

        planesProcesed++;
    }
Esempio n. 2
0
    public static bool checkRefuse(plane newPlane, planeAction action)
    {
        if (landingQ.Count >= 5 && action == planeAction.arrive)
        {
            Console.WriteLine("Plane " + newPlane.ID + " was turned away because there were too many planes waiting to land.");
            planesRefused++;
            return(true);
        }
        else if (takeOffQ.Count >= 5 && action != planeAction.depart)
        {
            Console.WriteLine("Plane " + newPlane.ID + " was turned away because there were too many planes waiting to take off.");
            planesRefused++;
            return(true);
        }

        return(false);
    }