unit Un_company;

interface
 uses Un_list, Un_Abonent;

 type TCompany=class
               private
               FNamecompany:string;
               FL:TList;
               public
               constructor Create (anamecompany:string);
               destructor Destroy; override;
               procedure Print;
               function Add_ab(Aabonent:TAbonent):boolean;
               function Del_ab (numberphone:TAbonent):boolean;
               function CompareCompany(Anamecompany:string):Integer;
               function Empty:Boolean;
               function Found(AAbonent:TAbonent):Boolean;
               function compareats(AAbonent:TAbonent;Anamecompany:string):integer;
               property namecompany:string read Fnamecompany;
               property L:Tlist read FL;
             end;

implementation

  constructor TCompany.Create;
begin
 inherited Create;
 FNamecompany:=Anamecompany;
 Init(Fl)
end;

 function TCompany.Add_ab(Aabonent:TAbonent):boolean;
  begin
    add_OrderL(FL,Aabonent)
  end;

 function TCompany.Found(AAbonent:TAbonent):Boolean;
 begin
    result:=False;
    if add_AbonentL(FL,AAbonent) then
      result:=true
 end;

  destructor TCompany.Destroy;
  begin
    ClearL(FL);
    inherited Destroy
  end;

  procedure TCompany.Print;
  begin
    writeln(#10,FNamecompany,':');
    PrintL(FL)
  end;

  function TCompany.Del_ab(numberphone:TAbonent):boolean;
  var p:TList;
  begin
    Del_abonentL(FL,numberphone);
  end;

  function TCompany.Empty:Boolean;
  begin
    result:=EmptyL(FL)
  end;

  function Tcompany.compareats(AAbonent:TAbonent;Anamecompany:string):integer;
  begin
    result:=Search(Fl,Aabonent)
  end;

  function TCompany.CompareCompany;
  begin
    if FNamecompany=Anamecompany then result:=0
                                  else
    if FNamecompany<Anamecompany then result:=-1
                                  else result:=1;
  end; 

end.
