traffic light pseudo code how to implement it in c++

Hello Everyone, i hope everyone is fine , i wrote a pseudo code in how the traffic light works where there is one intersection with one way traffic each side ,the demand based on controller which response to the preprogrammed timer based on real time sensor detection on a certain road junction.
and my problem is i wanna implement it in C++ but i couldn't find the easiest way to represent it.

PSEUDO CODE:

a=Calculate(1)
b=Calculate(2)
X1=0
X2=0
max=60 sec
IF (a≥ b) THEN
DO
TrafficLight_1(a,b, 1,2)

while(program is running)
ElSE
DO
TrafficLight_1(b,a,2,1)

while(program is running)

TrafficLight_1 FUNCTION:
TrafficLight_1(&n1,&n2, i, j)
{
timer=1
while(n1>OSi and timer !=max )
IF (TRj.GREEN EQUEL True)
TRj.YELLOW=True
TRj.RED=True
TRi.GREEN=True
timer++

IF (n1>0) AND (n2!=0)
TRi.YELLOW=True
TRi.RED=True
timer=1
IF (n2 != 0)
while(n2>OSj and timer !=max)
TRj.GREEN=True
timer++
n1=Calculate(i)
if (n1>0)
IF (TRj.GREEN EQUEL True)
TRj.YELLOW=True
TRj.RED=True

n2=Calculate(j)
}

Calculate FUNCTION:
Calculate(i)
{
n=ISi+(xi-OSi)
Xi=n
Return n
}



thanks everyone and sorry for the bother =)..
Unless someone is feeling very, very generous, you're not going to get anyone to sit down and essentially write your entire program for you. If you can at least attempt to write it in non-pseudo code we can then give you tips on where you've gone wrong. What you're asking us to do is a bit unrealistic. If you have more specific questions, such as the implementation of a certain algorithm or certain coding logic that's one thing, but currently that's not what I see you asking.
sorry for that .. but what i meant that i want an idea to represent the traffic light and i put my own pseudo code to understand my program not writing it for me because it's easy for me to write my pseudo code in c++ .. i just don't want to write for example cout<<"GREEN" .. i'm just asking if you have another way to implement the traffic light how it's turn to red , yellow and green and the movement of the cars .. .

sorry again that you didn't get what i meant at beginning ..
thank you,
Topic archived. No new replies allowed.