Exemplo n.º 1
0
    //Method name: westLigth
    //Method description: functionality from west light
    public void westLight(ref StopLight west, ref StopLight north)
    {
        //get west color
        west2 = west.getColor();
        west.timer(west.count);

        //check if color changed
        if (string.Equals(west2, "Green") && string.Equals("Yellow", west.getColor()))
        {
            west.lightChanged = true;
        }

        //west changed to red set north to green
        if (string.Equals(west2, "Yellow") && string.Equals("Red", west.getColor()))
        {
            west.count = 0;
            north.setGreen();
            west.lightChanged = true;
            north.count       = 0;
        }

        //increase count if green or yellow
        if (string.Equals("Green", west.getColor()) || string.Equals("Yellow", west.getColor()))
        {
            west.count++;
        }
    }
Exemplo n.º 2
0
    //Method name: southLigth
    //Method description: functionality from south light
    public void southLight(ref StopLight south, ref StopLight east)
    {
        //get souths color
        south2 = south.getColor();
        south.timer(south.count);


        //check to see if color changed
        if (string.Equals(south2, "Green") && string.Equals("Yellow", south.getColor()))
        {
            south.lightChanged = true;
        }

        //if south is red set east to green
        if (string.Equals(south2, "Yellow") && string.Equals("Red", south.getColor()))
        {
            south.count = 0;
            east.setGreen();
            south.lightChanged = true;
            east.count         = 0;
        }

        //increase count if south is green or yellow
        if (string.Equals("Green", south.getColor()) || string.Equals("Yellow", south.getColor()))
        {
            south.count++;
        }
    }
Exemplo n.º 3
0
    //Method name: eastLigth
    //Method description: functionality from east light
    public void eastLight(ref StopLight east, ref StopLight west)
    {
        //get easts color
        east2 = east.getColor();
        east.timer(east.count);


        //check to see if color changed
        if (string.Equals(east2, "Green") && string.Equals("Yellow", east.getColor()))
        {
            east.lightChanged = true;
        }


        if (string.Equals(east2, "Yellow") && string.Equals("Red", east.getColor()))
        {
            east.lightChanged = true;
            east.count        = 0;
        }
        //increase east count if green or yellow
        if (string.Equals("Green", east.getColor()) || string.Equals("Yellow", east.getColor()))
        {
            east.count++;
        }

        //set west to green
        if (east.count == 7)
        {
            west.setGreen();
            west.lightChanged = true;
            west.count        = 0;
        }
    }
Exemplo n.º 4
0
    //Method name: northLigth
    //Method description: functionality from north light
    public void northLight(ref StopLight north, ref StopLight south)
    {
        //get norths color before calling function
        north2 = north.getColor();
        north.timer(north.count);

        //check to see if color has changed
        if (string.Equals(north2, "Green") && string.Equals("Yellow", north.getColor()))
        {
            north.lightChanged = true;
        }

        //light changed
        if (string.Equals(north2, "Yellow") && string.Equals("Red", north.getColor()))
        {
            north.lightChanged = true;
            count = 0;
        }

        //increase count if ligth is green or yellow
        if (string.Equals("Green", north.getColor()) || string.Equals("Yellow", north.getColor()))
        {
            count++;
        }

        if (count == 7)
        {
            south.setGreen();
            south.lightChanged = true;
            south.count        = 0;
        }
    }