-
Notifications
You must be signed in to change notification settings - Fork 6
/
shop.cpp
174 lines (141 loc) · 4.03 KB
/
shop.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
#ifndef shop_cpp
#define shop_cpp
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ulli;
#include "shopkeeper.cpp"
#include "item.cpp"
class Shop
{
public:
ulli ID;
// char type[51];
char name[51];
char category[51];
char description[501];
// time_t timing;
char email[51];
bool working_days[7];
// ulli no_of_items;
void search_item();
Shop(int id=0)
{
ID=id;
}
int get_details(char shopkeeper_email[],char name[],char category[])
{
strcpy(email,shopkeeper_email);
strcpy(Shop::name,name);
strcpy(Shop::category,category);
char waste;
string description;
cout<<"> Enter a short discription of your shop(250 character max without enter)\n> ";
cin>>waste;
getline(cin,description);
if(description.length()>250)
{
cout<<"> Entered Description greater than 250 characters";
return -1;
}
Utilities::convert(description,Shop::description);
char answer;
cout<<"> Is your shop open on Sunday? (y/n) ";
cin>>answer;
if(answer=='y')
working_days[0]=true;
else if(answer=='n')
working_days[0]=false;
else
{
cout<<"> Invalid case selected";
return -1;
}
cout<<"> Is your shop open on Monday? (y/n) ";
cin>>answer;
if(answer=='y')
working_days[1]=true;
else if(answer=='n')
working_days[1]=false;
else
{
cout<<"> Invalid case selected";
return -1;
}
cout<<"> Is your shop open on Tuesday? (y/n) ";
cin>>answer;
if(answer=='y')
working_days[2]=true;
else if(answer=='n')
working_days[2]=false;
else
{
cout<<"> Invalid case selected";
return -1;
}
cout<<"> Is your shop open on Wednesday? (y/n) ";
cin>>answer;
if(answer=='y')
working_days[3]=true;
else if(answer=='n')
working_days[3]=false;
else
{
cout<<"> Invalid case selected";
return -1;
}
cout<<"> Is your shop open on Thursday? (y/n) ";
cin>>answer;
if(answer=='y')
working_days[4]=true;
else if(answer=='n')
working_days[4]=false;
else
{
cout<<"> Invalid case selected";
return -1;
}
cout<<"> Is your shop open on Friday? (y/n) ";
cin>>answer;
if(answer=='y')
working_days[5]=true;
else if(answer=='n')
working_days[5]=false;
else
{
cout<<"> Invalid case selected";
return -1;
}
cout<<"> Is your shop open on Saturday? (y/n) ";
cin>>answer;
if(answer=='y')
working_days[6]=true;
else if(answer=='n')
working_days[6]=false;
else
{
cout<<"> Invalid case selected";
return -1;
}
return 0;
}
void add_items(char name[],unsigned long long int ID){
string name1(name);
Item temp;
temp.get_item_details(name1,ID);
cout << "\n> Item added to shop\n";
//opening a file with the category of the shop and storing the item details
string path;
path = "database/shop_items/" + name1 + ".ooad";
ofstream file(path.c_str(), std::ios::app);
if (!file)
{
cout<<"problem in file IO :(";
exit(0);
}
file.seekp(0L, ios::end);
file.write((char *)&temp, sizeof(Item));
file.close();
cout<<"\n";
}
};
#endif