forked from kevin2000141/TubesDasPro
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathF5.pas
More file actions
51 lines (48 loc) · 1.56 KB
/
F5.pas
File metadata and controls
51 lines (48 loc) · 1.56 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
unit F5;
interface
uses uDef,F1;//untuk ngambil data
function inv (NBahanM,NBahanO,j: integer ; c : Asimulasi ): Boolean ; //gak perlu dipanggil
procedure beliBahan(var a:Ainventori{type dari F1};
d:Abahanmentah{untuk data bahan};
var b,e:integer{neff inv bahan};
var c:Asimulasi{type dari soal});
implementation
function inv(NBahanM,NBahanO,j:integer;c : Asimulasi ):Boolean;
begin
if (((NBahanM+NBahanO)<c[NSim].maxInventori))
then begin
inv := True;
end else
begin
inv :=False;
end;
end;
procedure beliBahan(var a:Ainventori{type inv dari F1};d:Abahanmentah{untuk data bahan};var b,e:integer{neff inv bahan};var c:Asimulasi{type dari soal});
var
namabahan:string;
i,j:longint;
begin{satu kali prosedur satu kali beli satu unit}
write('nama bahan :' );
readln(namabahan);{asumsi nama bahan terdapat dalam file}
write('kuantitas : ');
readln(j);
write('total harga : ');
i:=1;
while not(namabahan=d[i].nama) do
begin
i:=i+1;
end;
writeln(d[i].harga*j);
if ((inv (b,e,j,c))and (c[NSim].tEnergi>0) and (c[NSim].tUang >= (d[i].harga*j)) ) then
begin
b:=b+1;{neff baru(total bahan mentah dibeli)}
c[NSim].tEnergi:=c[NSim].tEnergi-1;{energibaru}
{a[b].nama := namabahan; a[b].tanggal :=;
a[b].jumlah := j;}
c[NSim].tPengeluaran:=c[NSim].tPengeluaran+(d[i].harga*j);{total pengeluaran}
c[NSim].tUang:=c[NSim].tUang-(d[i].harga*j);{pendapatan bersih berkurang}
c[NSim].tBMentahDibeli := c[NSim].tBMentahDibeli + j ;
writeln('berhasil dibeli');
end else writeln('gagal dibeli');
end;
end.