I need a delphi solution for this solution in java JAVA CODE
type
TColors = (red, green, blue, white, purple, orange, yellow, black);
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var Form1: TForm1;
implementation
{$R *.fmx}
function RandomColor: TColors;
begin
result := blue; // make this random value from enum ????
end;
procedure TForm1.Button1Click(Sender: TObject);
var
s: string;
begin
s := GetEnumName(TypeInfo(TColors), integer(RandomColor));
Memo1.Lines.Add(s); /// print random color to memo
end;
function RandomColor: TColors;
begin
Result := TColors(Random(Succ(Ord(High(TColors)))));
end;
var
MyColor: TColors;
begin
Randomize; //call this once at startup
MyColor := RandomColor;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With