Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Unit1;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.StdCtrls,
- Vcl.Samples.Spin, Vcl.ComCtrls, DateUtils;
- type
- TForm1 = class(TForm)
- Panel1: TPanel;
- Panel2: TPanel;
- Panel3: TPanel;
- Panel4: TPanel;
- Panel5: TPanel;
- InputDigits: TGroupBox;
- Button1: TButton;
- Button2: TButton;
- Button3: TButton;
- Button4: TButton;
- Button5: TButton;
- Button6: TButton;
- Button7: TButton;
- Button8: TButton;
- Button9: TButton;
- DigitsBoard: TGroupBox;
- Button11: TButton;
- ShownDigits: TLabel;
- GroupBox3: TGroupBox;
- Button12: TButton;
- RadioGroup1: TRadioGroup;
- Timer1: TTimer;
- DigitsPanel: TPanel;
- Button10: TButton;
- GroupBox1: TGroupBox;
- SpinEdit1: TSpinEdit;
- Label1: TLabel;
- GroupBox2: TGroupBox;
- ListView1: TListView;
- procedure Button12Click(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure Timer1Timer(Sender: TObject);
- function GiveMeStars(Count: integer): string;
- procedure Button1Click(Sender: TObject);
- procedure AddDigit(aDigit: integer);
- procedure CheckResult;
- procedure Button2Click(Sender: TObject);
- procedure Button3Click(Sender: TObject);
- procedure Button4Click(Sender: TObject);
- procedure Button5Click(Sender: TObject);
- procedure Button6Click(Sender: TObject);
- procedure Button7Click(Sender: TObject);
- procedure Button8Click(Sender: TObject);
- procedure Button9Click(Sender: TObject);
- procedure Button10Click(Sender: TObject);
- procedure Button11Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form1: TForm1;
- digits: array[1..5] of integer;
- userdigits : string;
- RomeAlphabet: array[1..9] of ShortString;
- WordAlphabet: array[1..9] of ShortString;
- score: integer;
- time,nowtime:TDateTime;
- implementation
- {$R *.dfm}
- { TForm1 }
- procedure TForm1.AddDigit(aDigit: integer);
- var tempdigits: string;
- i: integer;
- dublicate: boolean;
- begin
- tempdigits := ShownDigits.Caption;
- dublicate := False;
- case aDigit of
- -1:begin
- if (tempdigits[5] in ['1'..'9']) then
- tempdigits[5] := '_'
- else Delete(tempdigits, length(tempdigits)-1, 1);
- end;
- 1..9:begin
- if tempdigits[Length(tempdigits)] = '_' then begin
- for i := 1 to Length(tempdigits)-1 do begin
- if StrToInt(tempdigits[i]) = aDigit then dublicate := True;
- end;
- if not dublicate then begin
- tempdigits[Length(tempdigits)] := IntToStr(aDigit)[1];
- if Length(tempdigits) <5 then begin
- tempdigits := tempdigits + '_';
- end;
- end;
- end;
- end;
- 10:begin
- userdigits := '';
- for i := 1 to Length(tempdigits) do begin
- if tempdigits[i] <> '_' then begin
- userdigits := userdigits + tempdigits[i];
- if i<5 then userdigits := userdigits + ',';
- end;
- end;
- CheckResult;
- end;
- end;
- ShownDigits.Caption := tempdigits;
- end;
- procedure TForm1.Button10Click(Sender: TObject);
- begin
- AddDigit(-1);
- end;
- procedure TForm1.Button11Click(Sender: TObject);
- begin
- score := 0;
- AddDigit(10);
- end;
- procedure TForm1.Button12Click(Sender: TObject);
- var
- i, j: Integer;
- stop: boolean;
- begin
- ShownDigits.Caption := '_';
- for i := 1 to 5 do begin
- repeat
- stop := true;
- if RadioGroup1.ItemIndex = 2 then digits[i] := Random(9)+1;
- digits[i] := Random(9)+1;
- for j := 1 to i-1 do
- if digits[i] = digits[j]
- then stop := false;
- until stop;
- end;
- case RadioGroup1.ItemIndex of
- 0:begin
- DigitsPanel.Font.Size := 60;
- Panel1.Caption := IntToStr(digits[1]);
- Panel2.Caption := IntToStr(digits[2]);
- Panel3.Caption := IntToStr(digits[3]);
- Panel4.Caption := IntToStr(digits[4]);
- Panel5.Caption := IntToStr(digits[5]);
- end;
- 1:begin
- DigitsPanel.Font.Size := 30;
- Panel1.Caption := RomeAlphabet[digits[1]];
- Panel2.Caption := RomeAlphabet[digits[2]];
- Panel3.Caption := RomeAlphabet[digits[3]];
- Panel4.Caption := RomeAlphabet[digits[4]];
- Panel5.Caption := RomeAlphabet[digits[5]];
- end;
- 2:begin
- DigitsPanel.Font.Size := 15;
- Panel1.Caption := WordAlphabet[digits[1]];
- Panel2.Caption := WordAlphabet[digits[2]];
- Panel3.Caption := WordAlphabet[digits[3]];
- Panel4.Caption := WordAlphabet[digits[4]];
- Panel5.Caption := WordAlphabet[digits[5]];
- end;
- 3:begin
- DigitsPanel.Font.Size := 13;
- Panel1.Caption := GiveMeStars(digits[1]);
- Panel2.Caption := GiveMeStars(digits[2]);
- Panel3.Caption := GiveMeStars(digits[3]);
- Panel4.Caption := GiveMeStars(digits[4]);
- Panel5.Caption := GiveMeStars(digits[5]);
- end;
- end;
- Panel1.Visible := True;
- Panel2.Visible := True;
- Panel3.Visible := True;
- Panel4.Visible := True;
- Panel5.Visible := True;
- Timer1.Interval := SpinEdit1.Value;
- Timer1.Enabled := True;
- end;
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- AddDigit(1);
- end;
- procedure TForm1.Button2Click(Sender: TObject);
- begin
- AddDigit(2);
- end;
- procedure TForm1.Button3Click(Sender: TObject);
- begin
- AddDigit(3);
- end;
- procedure TForm1.Button4Click(Sender: TObject);
- begin
- AddDigit(4);
- end;
- procedure TForm1.Button5Click(Sender: TObject);
- begin
- AddDigit(5);
- end;
- procedure TForm1.Button6Click(Sender: TObject);
- begin
- AddDigit(6);
- end;
- procedure TForm1.Button7Click(Sender: TObject);
- begin
- AddDigit(7);
- end;
- procedure TForm1.Button8Click(Sender: TObject);
- begin
- AddDigit(8);
- end;
- procedure TForm1.Button9Click(Sender: TObject);
- begin
- AddDigit(9);
- end;
- procedure TForm1.CheckResult;
- var i,j: integer;
- temp, temp2: string;
- begin
- for i := 1 to Length(ShownDigits.Caption) do begin
- if ShownDigits.Caption[i]<>'_' then begin
- for j := 1 to 5 do begin
- if StrToInt(ShownDigits.Caption[i]) = digits[j] then begin
- inc(score);
- break;
- end;
- end;
- end;
- end;
- Panel1.Visible := True;
- Panel2.Visible := True;
- Panel3.Visible := True;
- Panel4.Visible := True;
- Panel5.Visible := True;
- with ListView1.Items.Add do begin
- Caption := RadioGroup1.Items[RadioGroup1.ItemIndex];
- temp := '';
- case RadioGroup1.ItemIndex of
- 0:begin
- for i := 1 to 5 do begin
- temp := temp + IntToStr(digits[i]);
- if i < 5 then temp := temp + ',';
- end;
- end;
- 1:begin
- for i := 1 to 5 do begin
- temp := temp + RomeAlphabet[digits[i]];
- if i < 5 then temp := temp + ',';
- end;
- end;
- 2:begin
- for i := 1 to 5 do begin
- temp := temp + WordAlphabet[digits[i]];
- if i < 5 then temp := temp + ',';
- end;
- end;
- 3:begin
- for i := 1 to 5 do begin
- temp := temp + GiveMeStars(digits[i]);
- if i < 5 then temp := temp + ',';
- end;
- end;
- end;
- SubItems.Add(temp);
- SubItems.Add(userdigits);
- SubItems.Add(FloatToStr((MilliSecondsBetween(time,now)/1000))+'с');
- SubItems.Add(IntToStr(Round(score/5*100))+'%');
- end;
- ShowMessage('Ваш результат: '+IntToStr(Round(score/5*100))+'%');
- end;
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- Randomize;
- RomeAlphabet[1] := 'I';
- RomeAlphabet[2] := 'II';
- RomeAlphabet[3] := 'III';
- RomeAlphabet[4] := 'IV';
- RomeAlphabet[5] := 'V';
- RomeAlphabet[6] := 'VI';
- RomeAlphabet[7] := 'VII';
- RomeAlphabet[8] := 'VIII';
- RomeAlphabet[9] := 'IX';
- WordAlphabet[1] := 'ОДИН';
- WordAlphabet[2] := 'ДВА';
- WordAlphabet[3] := 'ТРИ';
- WordAlphabet[4] := 'ЧЕТЫРЕ';
- WordAlphabet[5] := 'ПЯТЬ';
- WordAlphabet[6] := 'ШЕСТЬ';
- WordAlphabet[7] := 'СЕМЬ';
- WordAlphabet[8] := 'ВОСЕМЬ';
- WordAlphabet[9] := 'ДЕВЯТЬ';
- end;
- function TForm1.GiveMeStars(Count: integer): string;
- var
- i: Integer;
- begin
- Result := '';
- for i := 1 to Count do Result := Result + '*';
- end;
- procedure TForm1.Timer1Timer(Sender: TObject);
- begin
- Panel1.Visible := False;
- Panel2.Visible := False;
- Panel3.Visible := False;
- Panel4.Visible := False;
- Panel5.Visible := False;
- time:=now;
- Timer1.Enabled := False;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement