-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunit1.pas
More file actions
171 lines (134 loc) · 4.26 KB
/
Copy pathunit1.pas
File metadata and controls
171 lines (134 loc) · 4.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
unit Unit1;
//{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
BtnPesanlagi: TButton;
BtnHapus: TButton;
ComboBoxDestinasi: TComboBox;
ComboBoxKelas: TComboBox;
EditJumlah: TEdit;
BtnCetak: TButton;
BtnKeluar: TButton;
lblprogram: TLabel;
lblsapa5: TLabel;
MemoHasil: TMemo;
LabelDestinasi: TLabel;
LabelKelas: TLabel;
LabelJumlah: TLabel;
procedure BtnBayarClick(Sender: TObject);
procedure BtnCetakClick(Sender: TObject);
procedure BtnKeluarClick(Sender: TObject);
procedure BtnHapusClick(Sender: TObject);
procedure ComboBoxDestinasiChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure MemoHasilChange(Sender: TObject);
private
procedure TampilkanHasil(Destinasi, Kelas: string; Jumlah, Total: Integer);
function HitungHarga(Destinasi, Kelas: string): Integer;
public
end;
var
Form1: TForm1;
TotalKeseluruhan, TotalHarga : integer;
implementation
{$R *.lfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
ComboBoxDestinasi.Items.Add('Siantar');
ComboBoxDestinasi.Items.Add('Tebing Tinggi');
ComboBoxDestinasi.Items.Add('Kisaran');
ComboBoxKelas.Items.Add('VIP');
ComboBoxKelas.Items.Add('Bisnis');
ComboBoxKelas.Items.Add('Ekonomi');
end;
procedure TForm1.MemoHasilChange(Sender: TObject);
begin
end;
function TForm1.HitungHarga(Destinasi, Kelas: string): Integer;
begin
if (Destinasi = 'Siantar') and (Kelas = 'VIP') then
Result := 500000
else if (Destinasi = 'Siantar') and (Kelas = 'Bisnis') then
Result := 350000
else if (Destinasi = 'Siantar') and (Kelas = 'Ekonomi') then
Result := 200000
else if (Destinasi = 'Tebing Tinggi') and (Kelas = 'VIP') then
Result := 400000
else if (Destinasi = 'Tebing Tinggi') and (Kelas = 'Bisnis') then
Result := 250000
else if (Destinasi = 'Tebing Tinggi') and (Kelas = 'Ekonomi') then
Result := 150000
else if (Destinasi = 'Kisaran') and (Kelas = 'VIP') then
Result := 600000
else if (Destinasi = 'Kisaran') and (Kelas = 'Bisnis') then
Result := 450000
else if (Destinasi = 'Kisaran') and (Kelas = 'Ekonomi') then
Result := 300000
else
Result := 0;
end;
procedure TForm1.TampilkanHasil(Destinasi, Kelas: string; Jumlah, Total: Integer);
begin
MemoHasil.Lines.Add('-------- Tiket Kereta Api --------');
MemoHasil.Lines.Add('');
MemoHasil.Lines.Add('Destinasi : Medan -> ' + Destinasi);
MemoHasil.Lines.Add('Kelas : ' + Kelas);
MemoHasil.Lines.Add('Jumlah Tiket: ' + IntToStr(Jumlah));
MemoHasil.Lines.Add('Total Harga : Rp.' + IntToStr(Total));
MemoHasil.Lines.Add('');
MemoHasil.Lines.Add('Total Keseluruhan: Rp.' + IntToStr(TotalKeseluruhan));
MemoHasil.Lines.Add('');
end;
procedure TForm1.BtnCetakClick(Sender: TObject);
var
Destinasi, Kelas: string;
JumlahTiket, HargaTiket: Integer;
begin
if (ComboBoxDestinasi.ItemIndex = -1) or (ComboBoxKelas.ItemIndex = -1) then
begin
ShowMessage('Silakan pilih destinasi dan kelas terlebih dahulu!');
Exit;
end;
if EditJumlah.Text = '' then
begin
ShowMessage('Silakan masukkan jumlah tiket!');
Exit;
end;
Destinasi := ComboBoxDestinasi.Text;
Kelas := ComboBoxKelas.Text;
JumlahTiket := StrToIntDef(EditJumlah.Text, 0);
if JumlahTiket <= 0 then
begin
ShowMessage('Jumlah tiket harus lebih dari 0!');
Exit;
end;
HargaTiket := HitungHarga(Destinasi, Kelas);
TotalHarga := HargaTiket * JumlahTiket;
TotalKeseluruhan := TotalKeseluruhan + TotalHarga;
TampilkanHasil(Destinasi, Kelas, JumlahTiket, TotalHarga);
EditJumlah.Text := '';
BtnCetak.Caption := 'Pesan Lagi';
end;
procedure TForm1.BtnBayarClick(Sender: TObject);
begin
showmessage('Pemb');
end;
procedure TForm1.BtnKeluarClick(Sender: TObject);
begin
showmessage('Terima Kasih Telah menggunakan layanan kami!');
Close;
end;
procedure TForm1.BtnHapusClick(Sender: TObject);
begin
MemoHasil.Clear;
TotalKeseluruhan := 0;
BtnCetak.Caption :='Cetak';
end;
procedure TForm1.ComboBoxDestinasiChange(Sender: TObject);
begin
end;
end.