Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created March 10, 2022 23:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/51aee12f43ba1c339e5074639b6515d2 to your computer and use it in GitHub Desktop.
Save parzibyte/51aee12f43ba1c339e5074639b6515d2 to your computer and use it in GitHub Desktop.
void menuAsignarVehiculo(struct LugarEstacionamiento lugares[CANTIDAD_CARROS + CANTIDAD_MOTOS])
{
char lecturaUsuario[MAXIMA_LONGITUD_CADENA] = "";
int lugar = 0;
int horas;
mostrarEstadoEstacionamiento(lugares);
while (1)
{
printf("Ingrese el lugar: ");
scanf("%d", &lugar);
if (lugar > 0 && lugar <= CANTIDAD_CARROS + CANTIDAD_MOTOS)
{
if (lugares[lugar - 1].estado == OCUPADO)
{
printf("Ocupado\n");
}
else
{
lugar = lugar - 1;
break;
}
}
else
{
printf("Numero no valido\n");
}
}
printf("Ingrese las horas que planea estar en el estacionamiento: ");
scanf("%d", &horas);
consumirNuevaLinea();
while (1)
{
printf("Ingrese las placas de");
if (lugares[lugar].tipo == TIPO_MOTO)
{
printf(" la moto: ");
}
else
{
printf(" el carro: ");
}
fgets(lecturaUsuario, MAXIMA_LONGITUD_CADENA, stdin);
lecturaUsuario[strcspn(lecturaUsuario, "\r\n")] = 0;
if (existeVehiculoConPlacaYTipo(lugares, lecturaUsuario, lugares[lugar].tipo))
{
printf("Ya existe un vehiculo del mismo tipo y con las mismas placas en el sistema\n");
}
else
{
break;
}
}
marcarEntradaVehiculo(lugares, lugar, lecturaUsuario, horas);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment