jerry  ray

jerry ray

  • NA
  • 1
  • 10.5k

AIS Pseudocode

Jan 6 2011 12:06 PM
Hi guys,

I'm new to pseudo code. So i need help in converting the following pseudo code's in C#.

IAISPattern = interface
    function GetItem(I: Integer): Integer;
    procedure SetItem(I: Integer; const Value: Integer);
    function GetSize: Integer;
    procedure SetSize(const Value: Integer);
    property Size : Integer read GetSize write SetSize;
    property Items [I : Integer] : Integer read GetItem write SetItem;
  end;

  TAISPattern = class(TComponent, IAISPattern)
  private
    FItems : array of Integer;
    function GetItem(I: Integer): Integer;
    procedure SetItem(I: Integer; const Value: Integer);
    function GetSize: Integer;
    procedure SetSize(const Value: Integer);
  public
    constructor Create(AOwner : TComponent); override;
    destructor Destroy; override;
    property Size : Integer read GetSize write SetSize;
    property Items [I : Integer] : Integer read GetItem write SetItem;
  end; 

//The FItems is a dynamic array

//The TAISPattern set is used to represent the self set and detector set in the artificial immune system.
unit UnitAISPatternSet;

interface

uses
  UnitAISPattern, Classes;

type

  IAISPatternSet = interface
    function GetPattern(I: Integer): IAISPattern;
    function GetCount: Integer;
    function AddPattern : IAISPattern;
    property Patterns [I : Integer] : IAISPattern read GetPattern;
    property Count : Integer read GetCount;
  end;

  TAISPatternSet = class(TComponent, IAISPatternSet)
  private
    function GetPattern(I: Integer): IAISPattern;
    function GetCount: Integer;
  public
    function AddPattern : IAISPattern;
    property Patterns [I : Integer] : IAISPattern read GetPattern;
    property Count : Integer read GetCount;
  end;

implementation

{ TAISPatternSet }

function TAISPatternSet.AddPattern: IAISPattern;
var
  New : TAISPattern;
begin
  New := TAISPattern.Create(Self);

  Result := New;
end;

end.

//