Olá eu não estou conseguindo fazer com que as mensagens apareçam na tela... se alguém quiser dar uma dica?
OBS: só aparece em empate.
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Edit1: TEdit;
Edit2: TEdit;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Edit2Change(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
maquina: array [1..3] of string;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
edit1.Text := 'Pedra';
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
edit1.Text := 'Papel';
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
edit1.Text := 'Tesoura';
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
Edit2.Text := maquina[Random(3) + 1];
if (Edit1.Text = Edit2.Text) then
begin
ShowMessage('Empate');
exit;
end;
if (Edit2.Text = 'pedra') and (Edit1.Text = 'papel') then
begin
ShowMessage('você perdeu');
end;
if (Edit2.Text = 'papel') and (Edit1.Text = 'pedra') then
begin
ShowMessage('você ganhou');
end;
if (Edit1.Text = 'papel') and (Edit2.Text = 'tesoura') then
begin
ShowMessage('você perdeu');
end;
if (Edit1.Text = 'tesoura') and (Edit2.Text = 'papel') then
begin
ShowMessage('você ganhou');
end;
if (Edit1.Text = 'tesoura') and (Edit2.Text = 'pedra') then
begin
ShowMessage('você perdeu');
end;
if (Edit1.Text = 'pedra') and (Edit2.Text = 'tesoura') then
begin
ShowMessage('você ganhou');
end;
end;
procedure TForm1.Edit2Change(Sender: TObject);
begin
edit2.Text := maquina[Random(3) + 1];
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Randomize;
maquina[1] := 'Pedra';
maquina[2] := 'Papel';
maquina[3] := 'Tesoura';
end;
end.