Hello,
I am developping a strategy game using Lazarus. In a first unit called Map, I defined the classes TProvince et TSquare (a square belongs to a province). In the Economy unit, I defined the following classes for the economic objects in a province or in a square : TProvinceEconomy, TSquareEconomy, TActivitySector (an industry in a square), Tware (a ware available in a province).

Classes which represent industries (e.g. Farming) inherit from TActivitySector. Classes which represent wares (e.g. wheat), inherit from Tware. Each industry produce uses several wares to produce a ware, and therefore should be associated with the TWare object. An industry belongs to a square economy. A ware belongs to a province economy.

I also defined a few abstract classes and interfaces in another unit to help with circular references. The Map unit has a reference on the Economy unit in its implementation part.

I hope my explaination is clear.

Map unit :
Code:
Unit Map
TProvince = class
FEconomy :  TAbstractProvinceEconomy; // A province economy
FSquare : array of TSquare; // The squares which belong to the province
constructor Create;
end;

TSquare = class
FProvince : TProvince; // The province the square belongs to.
FEconomy :  TAbstractSquareEconomy; // A square economy
constructor Create(AProvince : TProvince );
end;

constructor TProvince.Create;
begin
self.FEconomy := TProvinceEconomy.Create;
SetLength(self.FSquares, 2);
self.FSquares[0] := TSquare.Create(self);
end;
When creating a TSquare object, I give the province as a parameter, and I create a TSquareEconomy.

Economy unit :
Code:
Unit Economy
TWare = class(TAbstractWare)
FName : string;
end;

TProvinceEconomy = class(TAbstractProvinceEconomy)
FWares : array of TAbstractWare; // Liste of available wares
constructor Create;
end;

TSquareEconomy = class(TAbstractSquareEconomy)
FSectors : array of TActivitySector; // List of industries
end;

// Secteur d'activit?©
TActivitySector = class
FName : string;
// The ware produced by the industry
FWare : TWare;
constructor Create;
end;

// Secteur Agriculture (inherits from TActivitySector)
TFarming = class(TActivitySector)
constructor create;
end;

TWheat = class(TWare)
end;

constructor TProvinceEconomy.Create;
begin
SetLength(self.FWares, 2);
// The ware "wheat" is available.
self.FWares[0] := TWheat .Create;
end;

constructor TFarming.Create;
begin
// The ware we want to associate with the industry.
self.FWare := self.FEconomy.FSquare.FProvince.FEconomy.FWares[0] as TWheat;
end;
But it doesn't work. FWares[0] seems to be empty. So I don't know if I am using the right way. Could you help me ?