program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils,
  Windows,
  Un_Abonent in 'Un_Abonent.pas',
  Un_network in 'Un_network.pas';

var Abonent,numberphone:TAbonent;
    Network:TNetwork;
    file_name,namecompany:string;

procedure Create_Network(file_name:string;var network:TNetwork);
var t:TextFile;
networkname,namecompany:string;
abonent:TAbonent;
begin
  AssignFile(t,file_name);
  Reset(t);
  readln(t,networkname);
  Network:=TNetwork.create(networkname);
  while not eof(t) do
   begin
     readln(t,namecompany);
     abonent:=TAbonent.Create(t);
     network.add_network(namecompany,abonent);
   end;
  CloseFile(t)
end;

begin
  SetconsoleCP(1251);
  SetconsoleOutPutCP(1251);
  Writeln('Введите имя файла ');
  Readln(file_name);
  file_name:=file_name+'.txt';
  if (not FileExists(file_name)) then write('Файл не найден!!!')
  else
  begin
    create_network(file_name,network);
    Network.Print;
    Writeln('ВВедите оператора');
    Readln(namecompany);
    Writeln('ВВедите информацию о новом абоненте');
    Abonent:= TAbonent.Create_Read;
    Network.Add_network(namecompany,Abonent);
    Network.Print;
    Writeln;
    Writeln('Введите оператора');
    Readln(namecompany);
    writeln('ВВедите номер телефона');
    numberphone:=TAbonent.Create_numberphone;
    Network.del(namecompany,numberphone);
    Network.Print;
    Network.destroy;
  end;
  readln
end.




