Показать сообщение отдельно
  #7  
Старый 28.03.2013, 23:21
Igor22 Igor22 вне форума
Прохожий
 
Регистрация: 28.03.2013
Сообщения: 6
Версия Delphi: Delphi 7
Репутация: 10
По умолчанию

вот что получилось(реализация класса неполная):
interface
Код:
uses
  News,SysUtils;

const
  MaxNews = 10;

type
  TStringItemList = array [1..MaxNews] of TNews;

TSection=class 
  public  
    constructor Create(_SectionName:string;_NewsName:string);
    function DeleteNews(_NewsName: string): boolean;
    function FindNews(_NewsName: string): string;
  private      
    NewsList:TStringItemList;
    SectionName: String; 
    NextSection: TSection;
    Count: Integer; 
end;


implementation

constructor TSection.Create;
begin
  NextSection := nil;
  Count := 0;
end;



function TSection.FindNews(_NewsName: string):string;
var
 i:byte;
begin
  for i:=1 to GetCount do
    if NewsList[i].GetTitleName = _NewsName Then
    begin
      Result :=i;
      Exit;
    end;
  Result := 0;
end;

function TSection.DeleteNews(_NewsName:string): boolean;       
var
  i: Byte;
  Lst:TStringItemList;
begin
  Result := False;
  if count <> 0 then
  begin
    Lst := FindNews(_NewsName:string);
    if Lst:=NewsName then
    begin
      for i:=Lst[index] to Count-1 do NewsList[i] := NewsList[i+1];
      NewsList[Count] := nil;
      Dec(Count);      
      Result := True;
    end;
  end;
 end;

//если есть ошибки исправьте если несложно,заранее спасибо
Ответить с цитированием