Initial commit
This commit is contained in:
commit
441143482a
13 changed files with 230 additions and 0 deletions
48
empanada.c
Normal file
48
empanada.c
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
#include "empanada.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
void inicializarEmpanada(Empanada* e, const char* relleno) {
|
||||
strncpy(e->relleno, relleno, 29);
|
||||
e->tiempo_coccion = 5 + rand() % 6;
|
||||
e->tiempo_actual = 0;
|
||||
e->activa = 1;
|
||||
e->estado = CRUDA;
|
||||
|
||||
int azar = rand() % 100;
|
||||
if (azar < 5) {
|
||||
e->estado = CUANTICA;
|
||||
} else if (azar < 15) {
|
||||
e->estado = SIN_RELLENO;
|
||||
e->tiene_relleno = 0;
|
||||
} else {
|
||||
e->tiene_relleno = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void cocinar(Empanada* e) {
|
||||
if (e->activa == 0) return;
|
||||
if (e->estado == CUANTICA || e->estado == SIN_RELLENO || e->estado == QUEMADA) return;
|
||||
|
||||
e->tiempo_actual++;
|
||||
|
||||
if (e->tiempo_actual < e->tiempo_coccion) {
|
||||
e->estado = EN_COCINA;
|
||||
} else if (e->tiempo_actual == e->tiempo_coccion) {
|
||||
e->estado = LISTA;
|
||||
} else {
|
||||
e->estado = QUEMADA;
|
||||
}
|
||||
}
|
||||
|
||||
const char* estadoToString(Estado estado) {
|
||||
switch (estado) {
|
||||
case CRUDA: return "Cruda";
|
||||
case EN_COCINA: return "En cocina";
|
||||
case LISTA: return "Lista";
|
||||
case QUEMADA: return "Quemada";
|
||||
case CUANTICA: return "Cuantica";
|
||||
case SIN_RELLENO: return "Sin relleno";
|
||||
default: return "Desconocido";
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue