Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
30
Task/Menu/Delphi/menu.delphi
Normal file
30
Task/Menu/Delphi/menu.delphi
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
program Menu;
|
||||
|
||||
{$APPTYPE CONSOLE}
|
||||
|
||||
uses
|
||||
System.SysUtils;
|
||||
|
||||
function ChooseMenu(Options: TArray<string>; Prompt: string): string;
|
||||
var
|
||||
index: Integer;
|
||||
value: string;
|
||||
begin
|
||||
if Length(Options) = 0 then
|
||||
exit('');
|
||||
repeat
|
||||
writeln;
|
||||
for var i := 0 to length(Options) - 1 do
|
||||
writeln(i + 1, '. ', Options[i]);
|
||||
write(#10, Prompt, ' ');
|
||||
Readln(value);
|
||||
index := StrToIntDef(value, -1);
|
||||
until (index > 0) and (index <= length(Options));
|
||||
Result := Options[index];
|
||||
end;
|
||||
|
||||
begin
|
||||
writeln('You picked ', ChooseMenu(['fee fie', 'huff and puff', 'mirror mirror',
|
||||
'tick tock'], 'Enter number: '));
|
||||
readln;
|
||||
end.
|
||||
Loading…
Add table
Add a link
Reference in a new issue