-
traffic lights!!
i need some help here...
im tryin to make a program that simulates traffic lights at an intsection, using a some sort of time function from borland C++ like sleep() or somethin on those lines. basically what im tryin to do is have a text display sayin when the one side turns green, then yellow, then red, then left turn singal, then green again. (and i need this fer both sides of traffic) im am totally lost on how to do it. so what i want is a text program that tells when the light changes (on both sides). i would really really appreciate any assiastance as soon as possble thx.
-
Ok here is the program.. I have done this only for yellow, green and red.. You can modify it to add other function. I have also attached the executable file of the program. in case your complier does not support the headers i have used... Try running the executable. It is zipped
# include <iostream.h>
# include <conio.h>
# include <stdio.h>
# include <iostream.h>
# include <dos.h>
main()
{
clrscr();
int ti;
char cg[14]=" TRAFIC TRAFIC";
cout<<" How long do you want the delay to be between signals >> ";
cin>>ti;
clrscr();
for(int i=0;i<14;i++)
{
gotoxy(5,5+i);
cout<<cg[i];
delay(100);
}
ti=ti*100;
gotoxy(25,10);
cout<<" First side";
gotoxy(55,10);
cout<<" Second side";
int sig;
sig=56;
do
{
if(sig==26)
sig=56;
else
sig=26;
gotoxy(sig,12);
cout<<"green ";
gotoxy(sig,12);
cout<<"red ";
delay(ti);
gotoxy(sig,12);
cout<<"yellow ";
delay(ti);
gotoxy(sig,12);
cout<<"green ";
gotoxy(sig,12);
cout<<"Green ";
}
while(ti>0);
}