program obj_zas;

uses crt;

type Zasobnik=object
     private
      prvek: Array [1..10] of Integer;
      pocet: Byte;
      chyba: Boolean;
      TypChyby: String;
     public
      procedure init;
      procedure push(a:Integer);
      function pop:Integer;
      function full:Boolean;
      function empty:Boolean;
     end;

procedure Zasobnik.init;
var t: Byte;
begin
 for t:=1 to 10 do prvek[t]:=0;
 pocet:=0;
 chyba:=False;
end;

function Zasobnik.full: Boolean;
begin
 if pocet=10 then full:=True
             else full:=False;
end;

function Zasobnik.empty: Boolean;
begin
 if pocet=0 then empty:=True
            else empty:=False;
end;

procedure Zasobnik.push(a:Integer);
var t: Byte;
begin
 if Zasobnik.full=True then
 begin
  chyba:=True;
  TypChyby:='plny zasobnik!!!';
 end else
 begin
  prvek[pocet+1]:=a;
  inc(pocet,1);
  chyba:=False;
 end;
end;

function Zasobnik.pop:Integer;
begin
 if Zasobnik.empty=True then
 begin
  chyba:=True;
  TypChyby:='prazdny zasobnik!!!';
 end else
 begin
  dec(pocet,1);
  pop:=prvek[pocet+1];
  prvek[pocet+1]:=0;
  chyba:=False;
 end;
end;



var zas: Zasobnik;
    cislo: Integer;
    t,volba: Byte;


begin
zas.init;

repeat
 clrscr;

 writeln('1-vlozit');
 writeln('2-vybrat');

 readln(volba);

 case volba of

 1: begin
     clrscr;
     writeLn('zadej cislo:');
     readln(cislo);
     zas.push(cislo);
     if zas.chyba=True then writeLn(zas.TypChyby);

     if zas.pocet>0 then for t:=1 to zas.pocet do write(zas.prvek[t],' ');
     readln;
    end;

 2: begin
     clrscr;
     cislo:=zas.pop;
     if zas.chyba=True then writeLn(zas.TypChyby)
                       else writeln('vybrane cislo: ',cislo);

     if zas.pocet>0 then for t:=1 to zas.pocet do write(zas.prvek[t],' ');
     readln;
    end;
 end; {of Case}

until volba=9;
end.