This repository was archived by the owner on May 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBilling.h
More file actions
68 lines (59 loc) · 1.77 KB
/
Copy pathBilling.h
File metadata and controls
68 lines (59 loc) · 1.77 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
#pragma once
#include "Customer.h"
#include "Product.h"
#include<string>
#include "mapper.h"
using namespace System;
using namespace System::IO;
using namespace System::Text;
ref class Billing
{
private:
int BillID = 4000;
float TotalAmount = 0;
const int discount = 0.1;
cli::array<Product^>^ Prod;
cli::array<Cust^>^ Customer;
public:
cli::array<int^>^ SubTotal;
Billing() {
Prod = gcnew cli::array<Product^>(100);
Customer = gcnew cli::array<Cust^>(100);
BillID++;
}
float CalBill(cli::array<String^>^ P, cli::array<String^>^ C) {
Prod = mapper::map_product(P);
Customer = mapper::map_customer(C);
TotalAmount = 0; // Reset TotalAmount before calculating the bill
SubTotal = gcnew cli::array<int^>(Customer->Length); // Initialize SubTotal array here
for (int i = 0; i < Customer->Length; i++) {
if (Customer[i]->P != nullptr) {
for (int j = 0; j < Customer[i]->P->Length; j++) {
if (Prod != nullptr && Prod->Length > j && Customer[i]->P[j]->PName == Prod[j]->PName && Customer[i]->P[j]->weight == Prod[j]->weight) {
SubTotal[j] = Prod[j]->price * Customer[i]->P[j]->Quantity;
Customer[i]->P[j]->PID = Prod[j]->PID;
TotalAmount += *SubTotal[j];
break;
}
}
}
}
return TotalAmount;
}
float getAmount() {
return TotalAmount;
}
float getAmount(float dis) {
if (dis >= 0 && dis <= 1) {
float discountedAmount = TotalAmount * (dis);
return TotalAmount = TotalAmount - discountedAmount;
}
else {
return TotalAmount;
}
}
int GetID() {
// BillID++;
return BillID;
}
};