Sabtu, 24 Januari 2015

Program Akhir Softskill

Nama : ·         
52413515 - Dimas Rizki ·       
53413328 - Fauzi Pratama ·        
 55413951 - Muhammad Hamim


Form :



Listing :

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    btnStart: TButton;
    Button2: TButton;
    lblClick: TLabel;
    btn1: TButton;
    btn2: TButton;
    btn3: TButton;
    btn4: TButton;
    Label2: TLabel;
    lblScore: TLabel;
    Label4: TLabel;
    edtName: TEdit;
    Timer2: TTimer;
    Timer3: TTimer;
    lblBravo: TLabel;
    Timer1: TTimer;
    Label1: TLabel;
    Label3: TLabel;
    Timer4: TTimer;
    lblWkt: TLabel;
    Label6: TLabel;
    procedure Selesai;
    procedure btnStartClick(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure btn1Click(Sender: TObject);
    procedure btn2Click(Sender: TObject);
    procedure btn3Click(Sender: TObject);
    procedure btn4Click(Sender: TObject);
    procedure edtNameKeyPress(Sender: TObject; var Key: Char);
    procedure Timer2Timer(Sender: TObject);
    procedure Timer3Timer(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Timer4Timer(Sender: TObject);
  private
    { Private declarations }
  public
  Tukar, Score, Tanya,Waktu : Integer;
  Blink : Boolean;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
procedure TForm1.Selesai;
begin
Timer1.Enabled := False;
Timer4.Enabled := False;
btn1.Enabled := False;
btn2.Enabled := False;
btn3.Enabled := False;
btn4.Enabled := False;

lblScore.Visible := False;
edtName.Enabled := True;
edtName.SetFocus;

lblClick.Visible := False;
end;


procedure TForm1.btnStartClick(Sender: TObject);
begin
Score := 0;
Waktu := 60;
Tukar := 0;

lblScore.Visible := True;
lblClick.Visible := True;
lblClick.Left := 33;
lblBravo.Caption := '';
lblBravo.Visible := False;
edtName.Enabled := False;
edtName.Clear;

Timer1.Enabled := True;
Timer4.Enabled := True;
btn1.Enabled := True;
btn2.Enabled := True;
btn3.Enabled := True;
btn4.Enabled := True;
lblScore.Caption := '0';
lblWkt.Caption := '60';

end;

procedure TForm1.Timer1Timer(Sender: TObject);
var
CapTmp : String;
begin
CapTmp := btn1.Caption;
btn1.Caption := btn2.Caption;
btn2.Caption := btn3.Caption;
btn3.caption := btn4.Caption;
btn4.Caption := CapTmp;
Inc(Tukar);

end;

procedure TForm1.btn1Click(Sender: TObject);
begin
if btn1.Caption = 'x' then
Score := Score + 10
else
Score := Score - 5;

lblScore.Caption := IntToStr(Score);
end;

procedure TForm1.btn2Click(Sender: TObject);
begin
if btn2.Caption = 'x' then
Score := Score + 10
else
Score := Score - 5;

lblScore.Caption := IntToStr(Score);
end;

procedure TForm1.btn3Click(Sender: TObject);
begin
if btn3.Caption = 'x' then
Score := Score + 10
else
Score := Score - 5;

lblScore.Caption := IntToStr(Score);
end;

procedure TForm1.btn4Click(Sender: TObject);
begin
if btn4.Caption = 'x' then
Score := Score + 10
else
Score := Score - 5;

lblScore.Caption := IntToStr(Score);
end;

procedure TForm1.edtNameKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 Then
begin
lblBravo.Visible := True;
if Score >= 50 then
lblBravo.Caption := 'Selamat Anda Menang' + ' ' + edtName.Text
else
lblBravo.Caption := 'Not Lucky' + ' ' + edtName.Text;

btnStart.SetFocus;
end;
end;

procedure TForm1.Timer2Timer(Sender: TObject);
begin
Blink := not Blink;
if Blink then
lblBravo.Font.Color := clRed
else
lblBravo.Font.Color := clBlue;
end;


procedure TForm1.Timer3Timer(Sender: TObject);
begin
if lblClick.Left <= 230 Then
lblClick.Left := lblClick.Left + 1
else
lblClick.Left := 0;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
Tanya := Application.MessageBox('Apa kau yakin ingin keluar permainan ?',
'Confirmation', MB_YESNO + MB_ICONQUESTION);
if Tanya = 6 then
begin
Application.MessageBox('Terimakasih telah bermain', 'Byee. . Byee..', MB_OK + MB_ICONINFORMATION);
Application.Terminate;
end;
end;

procedure TForm1.Timer4Timer(Sender: TObject);
begin
if lblWkt.Caption = '0' then
Selesai
else
Waktu := Waktu - 1;
lblWkt.Caption := IntToStr(Waktu);
end;
end.

Output :



0 komentar:

Posting Komentar