-
Notifications
You must be signed in to change notification settings - Fork 0
/
driver_code.cpp
177 lines (144 loc) · 8.51 KB
/
driver_code.cpp
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
172
173
174
175
176
177
// Name: Kathan Sanghavi
// ID: 201901053
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <cstring>
#include "structs.h"
using namespace std;
int main()
{
Inventory *I = new Inventory;
Customer *C = new Customer;
// Manager
string name = "ABC";
char* name1 = new char[name.size()+1];
strcpy(name1,name.c_str());
Manager M(111,name1,I);
// Billing
Billing *B = new Billing(I,C);
// Dataset
long INVENTORY_DATASET[100][4] = {
{111100000001,1,100,20},{111100000002,2,110,20},{111100000003,3,120,20},{111100000004,4,130,20},{111100000005,5,140,20},{111100000006,6,150,20},{111100000007,7,160,20},{111100000008,8,170,20},{111100000009,9,180,20},{111100000010,10,190,20},
{111100000011,11,200,20},{111100000012,12,210,20},{111100000013,13,220,20},{111100000014,14,230,20},{111100000015,15,240,20},{111100000016,16,250,20},{111100000017,17,260,20},{111100000018,18,270,20},{111100000019,19,280,20},{111100000020,20,290,20},
{111100000021,21,300,20},{111100000022,22,310,20},{111100000023,23,320,20},{111100000024,24,330,20},{111100000025,25,340,20},{111100000026,26,350,20},{111100000027,27,360,20},{111100000028,28,370,20},{111100000029,29,380,20},{111100000030,30,390,20},
{111100000031,31,400,20},{111100000032,32,410,20},{111100000033,33,420,20},{111100000034,34,430,20},{111100000035,35,440,20},{111100000036,36,450,20},{111100000037,37,460,20},{111100000038,38,470,20},{111100000039,39,480,20},{111100000040,40,490,20},
{111100000041,41,500,20},{111100000042,42,510,20},{111100000043,43,520,20},{111100000044,44,530,20},{111100000045,45,540,20},{111100000046,46,550,20},{111100000047,47,560,20},{111100000048,48,570,20},{111100000049,49,580,20},{222200001111,50,590,20},
{222200001114,51,600,20},{222200001117,52,610,20},{222200001120,53,620,20},{222200001123,54,630,20},{222200001126,55,640,20},{222200001129,56,650,20},{222200001132,57,660,20},{222200001135,58,670,20},{222200001138,59,680,20},{222200001141,60,690,20},
{222200001144,61,700,20},{222200001147,62,710,20},{222200001150,63,720,20},{222200001153,64,730,20},{222200001156,65,740,20},{222200001159,66,750,20},{222200001162,67,760,20},{222200001165,68,770,20},{222200001168,69,780,20},{222200001171,70,790,20},
{222200001174,71,800,20},{222200001177,72,810,20},{222200001180,73,820,20},{222200001183,74,830,20},{222200001186,75,840,20},{222200001189,76,850,20},{222200001192,77,860,20},{222200001195,78,870,20},{222200001198,79,880,20},{222200001201,80,890,20},
{222200001204,81,900,20},{222200001207,82,910,20},{222200001210,83,920,20},{222200001213,84,930,20},{222200001216,85,940,20},{222200001219,86,950,20},{222200001222,87,960,20},{222200001225,88,970,20},{222200001228,89,980,20},{222200001231,90,990,20},
{222200001234,91,1000,20},{222200001237,92,1010,20},{222200001240,93,1020,20},{222200001243,94,1030,20},{222200001246,95,1040,20},{222200001249,96,1050,20},{222200001252,97,1060,20},{222200001255,98,1070,20},{222200001258,99,1080,20},{222200001261,100,1090,20},
};
long CUSTOMER_DATASET[100][3] = {
{9400000001,1,0},{9400000002,2,0},{9400000003,3,0},{9400000004,4,0},{9400000005,5,0},{9400000006,6,0},{9400000007,7,0},{9400000008,8,0},{9400000009,9,0},{9400000010,10,0},
{9400000011,11,0},{9400000012,12,0},{9400000013,13,0},{9400000014,14,0},{9400000015,15,0},{9400000016,16,0},{9400000017,17,0},{9400000018,18,0},{9400000019,19,0},{9400000020,20,0},
{9400000021,21,0},{9400000022,22,0},{9400000023,23,0},{9400000024,24,0},{9400000025,25,0},{9400000026,26,0},{9400000027,27,0},{9400000028,28,0},{9400000029,29,0},{9400000030,30,0},
{9400000031,31,0},{9400000032,32,0},{9400000033,33,0},{9400000034,34,0},{9400000035,35,0},{9400000036,36,0},{9400000037,37,0},{9400000038,38,0},{9400000039,39,0},{9400000040,40,0},
{9400000041,41,0},{9400000042,42,0},{9400000043,43,0},{9400000044,44,0},{9400000045,45,0},{9400000046,46,0},{9400000047,47,0},{9400000048,48,0},{9400000049,49,0},{9400000050,50,0},
{9400000051,51,0},{9400000052,52,0},{9400000053,53,0},{9400000054,54,0},{9400000055,55,0},{9400000056,56,0},{9400000057,57,0},{9400000058,58,0},{9400000059,59,0},{9400000060,60,0},
{9400000061,61,0},{9400000062,62,0},{9400000063,63,0},{9400000064,64,0},{9400000065,65,0},{9400000066,66,0},{9400000067,67,0},{9400000068,68,0},{9400000069,69,0},{9400000070,70,0},
{9400000071,71,0},{9400000072,72,0},{9400000073,73,0},{9400000074,74,0},{9400000075,75,0},{9400000076,76,0},{9400000077,77,0},{9400000078,78,0},{9400000079,79,0},{9400000080,80,0},
{9400000081,81,0},{9400000082,82,0},{9400000083,83,0},{9400000084,84,0},{9400000085,85,0},{9400000086,86,0},{9400000087,87,0},{9400000088,88,0},{9400000089,89,0},{9400000090,90,0},
{9400000091,91,0},{9400000092,92,0},{9400000093,93,0},{9400000094,94,0},{9400000095,95,0},{9400000096,96,0},{9400000097,97,0},{9400000098,98,0},{9400000099,99,0},{9400000100,100,0},
};
// Manager reads Inventory Dataset and uploads data to Inventory object.
Item *n = NULL;
for(int i=0;i<100;i++)
{
n = new Item;
n->ID = INVENTORY_DATASET[i][0];
name = to_string(INVENTORY_DATASET[i][1]);
name1 = new char[name.size()+1];
strcpy(name1,name.c_str());
n->Name = name1;
n->Rate = INVENTORY_DATASET[i][2];
n->Quantity = INVENTORY_DATASET[i][3];
M.Add_item(n);
}
// Billing object reads Customer Dataset and uploads data to Customer object.
CustomerData *cd = NULL;
for(int i=0;i<100;i++)
{
cd = new CustomerData;
cd->ID = CUSTOMER_DATASET[i][0];
name = to_string(CUSTOMER_DATASET[i][1]);
name1 = new char[name.size()+1];
strcpy(name1,name.c_str());
cd->Name = name1;
cd->Points = CUSTOMER_DATASET[i][2];
B->Add_Customer(cd);
}
// Shopping episode -- Test Case
long Customer_ID1 = 9400000011;
long Items[3] = {111100000011,222200001114,222200001234}; // Customer wants to buy these items. //More items can be added to Items and Quantities array to buy those.
int Quantities[3] = {3,1,2};
B = new Billing(Customer_ID1,I,C); // Billing object
int nI = sizeof(Items)/sizeof(Items[0]);
for(int i=0;i<nI;i++)
{
B->Buy_item(Items[i],Quantities[i]);
}
B->make_payment();
// Manager checks product information
long mItems[3] = {111100000011,222200001114,222200001234};
int nmI = sizeof(mItems)/sizeof(mItems[0]);
for(int i=0;i<nmI;i++)
{
M.Get_Product_Info(mItems[i]);
}
// ---------------------------------------------------------------------//
// Demo of other Functionalities
/* B->get_Customer_Information(Customer_ID1); // Check Customer Data.
// Adding some new Items
n = new Item;
n->ID = 115100000001;
n->Rate = 45.90;
n->Quantity = 100;
name = "Bread";
name1 = new char[name.size()+1];
strcpy(name1,name.c_str());
n->Name = name1;
M.Add_item(n);
n = new Item;
n->ID = 259100000001;
n->Rate = 100;
n->Quantity = 35;
name = "Butter";
name1 = new char[name.size()+1];
strcpy(name1,name.c_str());
n->Name = name1;
M.Add_item(n);
n = new Item;
n->ID = 365100000001;
n->Rate = 80;
n->Quantity = 70;
name = "Milk";
name1 = new char[name.size()+1];
strcpy(name1,name.c_str());
n->Name = name1;
M.Add_item(n);
// Shopping Episode
B = new Billing(9999999999,I,C);
B->Buy_item(259100000001,3);
B->Buy_item(115100000001,5);
B->Buy_item(365100000001,3);
B->Cancel_item(365100000001); // Customer wanted to cancel this item from list.
B->change_Quantity(115100000001,-2); // Customer wanted to change the quantity of product from list.
B->make_payment(); // As the customer is new, program will ask to provide name and will add this customer to database.
B->get_Customer_Information(9999999999); // Checking Customer Information
// Demo of other Manager Functionalities
M.Get_Product_Info(115100000001);
M.Update_item_Rate(115100000001,90);
M.change_stock(115100000001,100);
M.Update_item_Quantity(365100000001,60);
M.Get_Product_Info(115100000001);
M.Get_Product_Info(259100000001);
M.Get_Product_Info(365100000001);
cout<<M.Delete_item(259100000001)<<" deleted."<<"\n";
M.Get_Product_Info(259100000001);
cout<<"\n";*/
return 0;
}