-
Notifications
You must be signed in to change notification settings - Fork 0
/
building.pas
79 lines (66 loc) · 1.85 KB
/
building.pas
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
unit building;
interface
uses
SysUtils, DateUtils, Dialogs, mainDB;
type
TBuilding = class(tObject)
private
procedure calculate_paid;
public
constructor Create(buildingAddress: string; water, elec, refuse: double);
procedure debug_print;
var
water_bill, electricity_bill, refuse_bill: double;
water_paid, electricity_paid, refuse_paid: double;
Address: string;
Bills: array[0..3] of Double;
Paid: array[0..3] of Double;
end;
implementation
{ TBuilding }
constructor TBuilding.Create(buildingAddress: string;
water, elec, refuse: double);
begin
// creates
Address := buildingAddress;
electricity_bill := elec;
water_bill := water;
refuse_bill := refuse;
calculate_paid;
Bills[0] := water;
Bills[1] := elec;
Bills[2] := refuse;
Paid[0] := water_paid;
Paid[1] := electricity_paid;
Paid[2] := refuse_paid;
//debug_print;
end;
procedure TBuilding.debug_print;
begin
ShowMessage('Water Paid: ' + floattostr(water_paid)
+ #10#13 + 'Electricity Paid: ' + floattostr(electricity_paid)
+ #10#13 + 'Refuse Paid: ' + floattostr(refuse_paid));
end;
procedure TBuilding.calculate_paid;
begin
// this totals all the payments made this month for this building
with dbmMainDB do
begin
tblServices.First;
while not tblServices.Eof do
begin
if (tblServices['PropertyAddress'] = Address) and
(MonthOf(tblServices['PayedDate']) = MonthOf(Now)) then
begin
if tblServices['Type'] = 'Water' then
water_paid := water_paid + tblServices['AmountPaid']
else if tblServices['Type'] = 'Electricity' then
electricity_paid := electricity_paid + tblServices['AmountPaid']
else if tblServices['Type'] = 'Refuse' then
refuse_paid := refuse_paid + tblServices['AmountPaid'];
end;
tblServices.Next;
end;
end;
end;
end.