Скачиваний:
71
Добавлен:
10.12.2013
Размер:
4 Кб
Скачать
Unit prog1;
interface
Uses crt;


type

       PShop=^TShop;
       TShop=object
       private
             shopname:string;
       public
        constructor Init(shop1:string);
        procedure  setshop(sh:string);
        function   getshop:string;
        destructor Done;virtual;
        end;


       TCar=object(TShop)
       private
            age:integer;{бв ¦ }
            price:real;
       public

       public
        constructor Init(shop1:string;ag:integer;pr:real);
        destructor Done;virtual;

        procedure  setage(ag:integer);
        function   getage:integer;
        procedure  setprice(pr:real);
        function   getprice:real;
        procedure Add;
        procedure Delet;
        procedure Sort;
        procedure Show;
        end;

   Var     car:TCar;
            Cont:array[1..20] of TCar;
            count:integer;

        Implementation

       constructor TShop.Init(shop1:string);
       begin
         setshop(shop1);
       end;

       procedure  TShop.setshop(sh:string);
       begin
         shopname:=sh;
       end;

       function   TShop.getshop:string;
       begin
         getshop:=shopname;
       end;

       destructor TShop.Done;
       begin
       end;

{------------------------------------------------------------------------}

       constructor TCar.Init(shop1:string;ag:integer;pr:real);
       begin
       inherited init(shop1);
        setage(ag);
        setprice(pr);
       end;

       procedure TCar.Add;
       var s:string;
           a:integer;
           p:real;
       begin
        clrscr;
        writeln(' „®Ў ўм⥠ў Є®­Ґж бЇЁбЄ  ¤ ­­лҐ : ');
        count:=count+1;
        write(' ’®аЈ®ў®Ґ ЇаҐ¤ЇаЁпвЁҐ : ');readln(s);
        write(' ‚®§а бв  ўв®¬®ЎЁ«п   : ');readln(a);
        write(' –Ґ­                  : ');readln(p);
        cont[count].init(s,a,p);

        end;

       procedure TCar.Delet;
       var delnum,i:integer;
       begin
          clrscr;
          writeln(' “¤ «Ёвм ¤ ­­лҐ Ё§ бЇЁбЄ  Ї® ­®¬Ґаг : ');
          write(' Ќ®¬Ґа г¤ «Ґ¬ле ¤ ­­ле Ё§ бЇЁбЄ   : ');readln(delnum);
          for i:=delnum to count-1 do
           cont[i]:=cont[i+1];
           count:=count-1;

       end;

       procedure TCar.Sort;
       var i,j,ag:integer;
               pr:real;
               st:string;

       begin
           for i:=1 to count do
           for j:=count downto i do
           if cont[i].age>cont[j].age then
           begin
               ag:=cont[i].getage;
               st:=cont[i].getshop;
               pr:=cont[i].getprice;
               cont[i].setage(cont[j].getage);
               cont[i].setshop(cont[j].getshop);
               cont[i].setprice(cont[j].getprice);
               cont[j].setage(ag);
               cont[j].setshop(st);
               cont[j].setprice(pr);
                end;
       end;

       procedure TCar.Show;
       var i:integer;
       begin
         clrscr;
         for i:=1 to  count do
         begin
            writeln(cont[i].getshop);{}
            writeln(cont[i].getage);
            writeln(cont[i].getprice:2:3);
         writeln;
         writeln('Ќ ¦¬ЁвҐ «оЎго Є« ўЁиг ');
         readkey;
          readkey;
         end;
         writeln;
       end;
       procedure  TCar.setage(ag:integer);
       begin
         age:=ag;
       end;

       function   TCar.getage:integer;
       begin
          getage:=age;
       end;

       procedure  TCar.setprice(pr:real);
       begin
          price:=pr;
       end;

       function   TCar.getprice:real;
       begin
           getprice:=price;
       end;


      destructor TCar.Done;
      begin
      end;
{------------------------------------------------------------------------}

end.
Соседние файлы в папке климов_1