Skip to content

Commit 7adb32c

Browse files
enum & more stl
1 parent b1c7ceb commit 7adb32c

File tree

6 files changed

+97
-1
lines changed

6 files changed

+97
-1
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"files.associations": {
33
"iostream": "cpp",
4-
"ostream": "cpp"
4+
"ostream": "cpp",
5+
"ctime": "cpp"
56
}
67
}

Chaiaurcode/ecommerce_app.cpp

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#include<bits/stdc++.h>
2+
#include<ctime>
3+
using namespace std;
4+
5+
struct Product{
6+
int productId;
7+
string name;
8+
string category;
9+
};
10+
struct Order{
11+
int orderId;
12+
int productId;
13+
int quantity;
14+
string customerId;
15+
time_t orderData;
16+
};
17+
int main(){
18+
vector<Product> products = {
19+
{101,"Light","Electronics"},
20+
{102,"Laptop","Electronics"},
21+
{103,"Grinder","Home"},
22+
{104,"Shoes","Apparel"},
23+
{105,"Curtains","Home"},
24+
};
25+
26+
deque<string> recentCustomers = {"C001","C002","C003"};
27+
recentCustomers.push_back("C004");
28+
recentCustomers.push_back("C005");
29+
30+
list<Order> orderHistory;
31+
orderHistory.push_back({1,101,1,recentCustomers[1],time(0)});
32+
orderHistory.push_back({2,104,1,recentCustomers[0],time(0)});
33+
orderHistory.push_back({3,105,2,recentCustomers[4],time(0)});
34+
orderHistory.push_back({4,102,1,recentCustomers[2],time(0)});
35+
36+
set<string> categories;
37+
for(const auto &product:products){
38+
categories.insert(product.category);
39+
}
40+
41+
map<int, int> productStock = {
42+
{101, 5},
43+
{102, 25},
44+
{103, 10},
45+
{104, 55},
46+
{105, 6},
47+
};
48+
49+
multimap<string , Order> customerOrders;
50+
for(const auto &order:orderHistory){
51+
customerOrders.insert({order.customerId, order});
52+
}
53+
}

Chaiaurcode/ecommerce_app.exe

338 KB
Binary file not shown.

Chaiaurcode/employee.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include<iostream>
2+
#include<algorithm>
3+
#include<numeric>
4+
#include<iterator>
5+
#include<string>
6+
using namespace std;
7+
struct Employee{
8+
int id;
9+
string name;
10+
double salary;
11+
};
12+
13+
void display(const Employee& emp){
14+
cout<<"ID: "<<emp.id<<" ,Name: "<<emp.name<<" ,Salary: "<<emp.salary<<endl;
15+
}

Chaiaurcode/enum.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
enum Seat{
5+
MIDDLE = 10,
6+
AISLE,
7+
WINDOW
8+
};
9+
10+
int main(){
11+
enum Seat mySeat = MIDDLE;
12+
switch (mySeat)
13+
{
14+
case 10:
15+
cout<<"Middle";
16+
break;
17+
case 11:
18+
cout<<"Aisle";
19+
break;
20+
case 12:
21+
cout<<"Window";
22+
break;
23+
default:
24+
break;
25+
}
26+
// cout<<mySeat;
27+
}

Chaiaurcode/enum.exe

128 KB
Binary file not shown.

0 commit comments

Comments
 (0)