1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| type
TMachinType = (mtTruc, mtBidule, mtChose);
const
Machin_NAMES: array[TMachinType] of string = ('Truc', 'Bidule', 'Chose');
const
Machin_CLASSES: array[TMachinType] of TClass = (TObjectTruc, TObjectBidule, TObjectChose);
class function TMachinManager.GetEchantMachin(const MachinName: string): TClass;
var
iMachin: TMachinType;
begin
for iMachin := Low(TMachinType) to High(TMachinType) do
begin
if SameText(MachinName, Machin_NAMES[iMachin]) then
begin
Result := Machin_CLASSES[iMachin];
Exit;
end;
end;
Result := nil;
end; |
Partager