Registriert seit: 26. Mai 2004
3.159 Beiträge
|
Re: Wie testet man ob Enum in Teilgruppe davon?
3. Apr 2010, 18:56
Schöner wäre es wahrlich, aber dies bzgl fällt mir echt nichts ein Ich würde aber auf eine Hilfsmethode/-typ umsteigen und das wie folgt lösen:
Delphi-Quellcode:
type
TFixelType = (ftWall, ftBall, ftFinish,
ftRedBrush, ftGreenBrush, ftYellowBrush, ftBlueBrush,
ftAcid,
ftRedSwitch, ftGreenSwitch, ftYellowSwitch, ftBlueSwitch,
ftRedDoor, ftGreenDoor, ftYellowDoor, ftBlueDoor,
ftBumper, ftPad,
ftRedAccelerator, ftGreenAccelerator, ftYellowAccelerator, ftBlueAccelerator,
ftRedBeamstart, ftGreenBeamstart, ftYellowBeamstart, ftBlueBeamstart,
ftRedBeamtarget, ftGreenBeamtarget, ftYellowBeamtarget, ftBlueBeamtarget,
ftBlocker,
ftText);
const
DOOR_TYPES = [ftRedDoor, ftGreenDoor, ftYellowDoor, ftBlueDoor];
BRUSHES_TYPES = [ftRedBrush, ftGreenBrush, ftYellowBrush, ftBlueBrush];
type
TMyEnumType = (etNone, etDoorTypes, etBrushesTypes);
function MyEnumTypeOfFixelElement(const AFixelType: TFixelType): TMyEnumType;
begin
if (AFixelType in TYPES) then
Result := etDoorTypes
else if (AFixelType in BRUSHES_TYPES) then
Result := etBrushesTypes
else
Result := etNone;
end;
AElement := { was auch immer };
case MyEnumTypeOfFixelElement(AElement) of
etDoorTypes : ;
etBrushesTypes : ;
else begin
end;
end;
»Remember, the future maintainer is the person you should be writing code for, not the compiler.« (Nick Hodges)
|