Skip to content

Instantly share code, notes, and snippets.

@chrismedrdz
Created September 7, 2012 04:02
Show Gist options
  • Save chrismedrdz/3662987 to your computer and use it in GitHub Desktop.
Save chrismedrdz/3662987 to your computer and use it in GitHub Desktop.
Control de Semaforo
if (CarrilA > 10) { CA = true; }
if (CarrilB > 10) { CB = true; }
if (CarrilC > 5 ) { CC = true; }
if (CarrilD > 5 ) { CD = true; }
/*Ecuación Booleana que evalúa el Congestionamiento en los carriles para dar los permisos a los Semáforos Principales y Secundarios del Cruce*/
SemAB = (CA | CB | !CD ) & (CA | !CC | !CD ) & (CA | CB | !CC) & (CB | !CC | !CD);
SemCD = !SemAB;
ListaCarros LisCarr = new ListaCarros();
LisCarr.setEstado(SemAB,SemCD);
if (SemAB == true) {
EstadoAB = "Verde";
EstadoCD = "Rojo";
} else {
EstadoAB = "Rojo";
EstadoCD = "Verde";
}
for(int r=0;r<20;r++){System.out.println("\n");}
System.out.println("\t\t----------------------------------");
System.out.println("\t\t~Sistema de Control de Semaforos~");
System.out.println("\t\t----------------------------------");
System.out.println("\n\n\t\t~Congestionamiento~");
System.out.println("\n\tHay "+CarrilA+" carros en A");
System.out.println("\n\tHay "+CarrilB+" carros en B");
System.out.println("\n\tHay "+CarrilC+" carros en C");
System.out.println("\n\tHay "+CarrilD+" carros en D");
System.out.println("\n\n\t\t~Estado Semaforos~");
System.out.println("\n\tA y B -> "+EstadoAB );
System.out.println("\n\tC y D -> "+EstadoCD );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment