-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathF14.pas
More file actions
115 lines (102 loc) · 2.98 KB
/
F14.pas
File metadata and controls
115 lines (102 loc) · 2.98 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
// Nama File: F14.pas
// Deskripsi File: Unit prosedur lihat resep untuk program utama Engi's Kitchen
// Tanggal terakhir diubah: 22/04/2018
unit F14;
interface
uses uDef,sysutils;
{ Deklarasi Fungsi/Prosedur }
procedure lihatResep(var FEResep: AResep; NResep: Integer);
{Melihat daftar resep yang tersedia, termasuk semua daftar bahan penyusunnya}
{I.S : FEResep terdefinifisi, NResep merupakan jumlah dari resep}
{F.S : daftar resep serta bahan penyusunnya tertulis di layar}
implementation
{ Implementasi Fungsi/Prosedur }
procedure lihatResep(var FEResep: AResep; NResep: Integer);
{Melihat daftar resep yang tersedia, termasuk semua daftar bahan penyusunnya}
{I.S : FEResep terdefinifisi, NResep merupakan jumlah dari resep}
{F.S : daftar resep serta bahan penyusunnya tertulis di layar}
{KAMUS}
var
N: longint;
i,j,k:integer;
tukarInt:longint;
urutan: string;
tukarString : array [1..Nmax] of string;
{ALGORITMA}
begin
repeat
write('Penampilan terurut abjad "membesar" atau "mengecil" : ');
readln(urutan);
if not (lowercase(urutan) = 'membesar') and not (lowercase(urutan) = 'mengecil') then
begin
writeln('Input salah, masukkan lagi');
end;
until (lowercase(urutan) ='membesar') or (lowercase(urutan) = 'mengecil');
{Menampilkan isi resep sesuai abjad}
writeln('DAFTAR RESEP');
writeln('Nama Resep | Harga Jual | N | Bahan-1 | Bahan-2 |..| Bahan-N');
repeat
k:=0; i:=NResep;
for j:=1 to i do
begin
if (FEResep[j-1].nama > FEResep[j].nama) then
begin
tukarString[1] := FEResep[j-1].nama;
FEResep[j-1].nama := FEResep[j].nama;
FEResep[j].nama := tukarString[1];
tukarInt :=FEResep[j-1].harga;
FEResep[j-1].harga := FEResep[j].harga;
FEResep[j].harga :=tukarInt;
tukarInt :=FEResep[j-1].n;
FEResep[j-1].n := FEResep[j].n;
FEResep[j].n :=tukarInt;
for N:=1 to FEResep[j].n do
begin
tukarString[N] := FEResep[j-1].bahan[N];
end;
for N:=1 to FEResep[j-1].n do
begin
FEResep[j-1].bahan[N] := FEResep[j].bahan[N];
end;
for N:=1 to FEResep[j].n do
begin
FEResep[j].bahan[N] := tukarString[N];
end;
k := j;
end;
end;
i := k;
until i = 0;
if (urutan = 'membesar') then
begin
i := 1;
while (NResep>=i) do
begin
write (FEResep[i].nama, ' | ', FEResep[i].harga, ' | ', FEResep[i].n, ' | ');
j := 1;
while (FEResep[i].n>j) do
begin
write (FEResep[i].bahan[j], ' | ');
j := j+1;
end;
writeln (FEResep[i].bahan[j]);
i := i+1;
end;
end else
begin
i := NResep;
while (i>=1) do
begin
write (FEResep[i].nama, ' | ', FEResep[i].harga, ' | ', FEResep[i].n, ' | ');
j := 1;
while (FEResep[i].n>j) do
begin
write (FEResep[i].bahan[j], ' | ');
j := j+1;
end;
writeln (FEResep[i].bahan[j]);
i := i-1;
end;
end;
end;
end.