Professional Documents
Culture Documents
using System.Drawing;
using System.Windows.Forms;
using System.IO;
using System.Threading;
class Caja:Form {
private Pila pila_caja;
public Caja() {
this.pila_caja= new Pila();
this.Paint += new PaintEventHandler(Pintar);
}
while (archivo.Peek()>0) {
linea= archivo.ReadLine();
aEvento= linea.Split(',');
e.Graphics.Clear(Color.White);
e.Graphics.DrawString("Evento: "+linea,
new Font("Arial",10),
new SolidBrush(Color.Black),
0,
0);
switch (aEvento[0].ToUpper()) {
case "NUEVO_LIBRO":
this.pila_caja.Push(new elemento_de_pila(aEvento[1], ++prioridad));
break;
case "LEYENDO_LIBRO":
leyendo_libro= this.pila_caja.Pop();
break;
}
this.pila_caja.Pintar(e.Graphics);
Thread.Sleep(2000);
}
e.Graphics.Clear(Color.Black);
}
class Pila {
private elemento_de_pila[] e= new elemento_de_pila[1000];
private int primero;
private int ultimo;
private int cuantos_elementos;
public Pila() {
this.primero= -1;
this.ultimo= -1;
this.cuantos_elementos= 0;
}
if (this.cuantos_elementos>0) {
seleccionado= e[this.ultimo];
this.ultimo--;
this.cuantos_elementos--;
if (this.cuantos_elementos==0)
this.primero= -1;
}
return(seleccionado);
}
class elemento_de_pila {
private string libro;
private int numero_orden;