Skip to content

Commit 248bbbe

Browse files
committed
E-Shop
Shop platform with C++
1 parent 6b8897d commit 248bbbe

22 files changed

+485
-0
lines changed

E-Shop/Admin.h

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#pragma once
2+
class Admin {
3+
public:
4+
static int _staticId;
5+
int _id;
6+
string _username;
7+
string _password;
8+
Admin(string username, string password){
9+
_id=_staticId++;
10+
_username=username;
11+
_password=password;
12+
}
13+
14+
int getId() { return _id; }
15+
string getUsername() { return _username; }
16+
string getPassword() { return _password; }
17+
};
18+
19+
int Admin::_staticId = 0;

E-Shop/Customer.h

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#pragma once
2+
3+
class Customer {
4+
static int _staticID;
5+
int _id;
6+
string _name;
7+
string _password;
8+
9+
public:
10+
11+
Customer(string name, string password) {
12+
13+
_id = _staticID++;
14+
_name = name;
15+
_password = password;
16+
}
17+
18+
int getId(){ return _id; }
19+
string getUsername(){ return _name; }
20+
string getPassword() { return _password; }
21+
22+
23+
24+
};
25+
int Customer::_staticID = 0;

E-Shop/Database.h

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#pragma once
2+
3+
class Database {
4+
vector<Admin> admins;
5+
vector<Customer> customers;
6+
vector<ProductItem>_productitem;
7+
vector<Product>_product;
8+
public:
9+
10+
void ShowAllProducts()
11+
{
12+
for (size_t i = 0; i < _productitem.size(); i++)
13+
{
14+
cout << _productitem[i] << endl;
15+
}
16+
}
17+
18+
void UpdateProduct() {
19+
int id;
20+
int newPrice;
21+
string newName, newColor;
22+
cout << "\t\t\t\t\t\tEnter product id : ";
23+
cin >> id;
24+
for (size_t i = 0; i < _productitem.size(); i++)
25+
{
26+
if (_productitem[i].getId() == id)
27+
{
28+
cout << "Name: " << endl;
29+
cin >> newName;
30+
cout << "Price: " << endl;
31+
cin >> newPrice;
32+
cout << "Color: " << endl;
33+
cin >> newColor;
34+
_product[i]._name = newName;
35+
_product[i]._color = newColor;
36+
_product[i]._price = newPrice;
37+
}
38+
}
39+
}
40+
};

E-Shop/E-Shop.cpp

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
#include <iostream>
2+
using namespace std;
3+
#include <conio.h>
4+
#include <vector>
5+
#include "Admin.h"
6+
#include "Customer.h"
7+
#include "Product.h"
8+
#include "Database.h"
9+
10+
11+
12+
int main(){
13+
Database d;
14+
Admin a{"admin","admin123"};
15+
Customer c{ "Huseyn","Huseyn123" };
16+
Product p{ "Coca Cola",1,"Red" };
17+
ProductItem{ 1,&p };
18+
int choice;
19+
char ch;
20+
string username;
21+
string password;
22+
menu:
23+
24+
cout<<"\t\t\t\t\t\tWelcome E - Shop !!!!!!!!!!"<<endl;
25+
cout << "\t\t\t\t\t-----------------------------------------" << endl;
26+
cout<<"\t\t\t\t\t\t[1]Admin"<<endl;
27+
cout<<"\t\t\t\t\t\t[2]Customer"<<endl;
28+
cout<<"\t\t\t\t\t\t[3]Exit"<<endl;
29+
cout<<"\t\t\t\t\t\tPlease select : ";
30+
cin >> choice;
31+
system("cls");
32+
switch (choice){
33+
case 1:
34+
cout << "\t\t\t\t\t\tEnter username: ";
35+
cin >> username;
36+
cout << "\t\t\t\t\t\tEnter password: ";
37+
ch = _getch();
38+
while (ch!=13){
39+
password.push_back(ch);
40+
cout << '*';
41+
ch = _getch();
42+
}
43+
cout << endl;
44+
if (username == a.getUsername() && password == a.getPassword()) {
45+
int Adminchoice;
46+
system("cls");
47+
cout << "ADMIN REGISTERED" << endl;
48+
cout << "\t\t\t\t\t\t [1]Show all products" << endl;
49+
cout << "\t\t\t\t\t\t [2]Update product" << endl;
50+
cout << "\t\t\t\t\t\t [3]Delete product" << endl;
51+
cout << "\t\t\t\t\t\t Enter choice: ";
52+
cin >> Adminchoice;
53+
if (Adminchoice == 1)
54+
d.ShowAllProducts();
55+
else if (Adminchoice == 2)
56+
d.UpdateProduct();
57+
}
58+
59+
else
60+
cout << "Invalid username or password !!!"<<endl;
61+
break;
62+
case 2:
63+
cout << "\t\t\t\t\t\tEnter username: ";
64+
cin >> username;
65+
cout << "\t\t\t\t\t\tEnter password: ";
66+
ch = _getch();
67+
while (ch != 13) {
68+
password.push_back(ch);
69+
cout << '*';
70+
ch = _getch();
71+
}
72+
cout << endl;
73+
if (username == c.getUsername() && password == c.getPassword()) {
74+
int Customerchoice;
75+
system("cls");
76+
cout << "CUSTOMER REGISTERED" << endl;
77+
cout << "\t\t\t\t\t\t [1]Show all products" << endl;
78+
cout << "\t\t\t\t\t\t [0]Exit" << endl;
79+
cout << "Enter choice: ";
80+
cin >> Customerchoice;
81+
if (Customerchoice == 1)
82+
d.ShowAllProducts();
83+
else if (Customerchoice == 0)
84+
exit(0);
85+
}
86+
break;
87+
88+
case 3:
89+
cout << "See you later ..." << endl;
90+
exit(0);
91+
break;
92+
default:
93+
goto menu;
94+
break;
95+
}
96+
97+
98+
99+
100+
101+
102+
103+
104+
}

E-Shop/E-Shop.vcxproj

+142
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="Debug|x64">
13+
<Configuration>Debug</Configuration>
14+
<Platform>x64</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Release|x64">
17+
<Configuration>Release</Configuration>
18+
<Platform>x64</Platform>
19+
</ProjectConfiguration>
20+
</ItemGroup>
21+
<PropertyGroup Label="Globals">
22+
<VCProjectVersion>16.0</VCProjectVersion>
23+
<Keyword>Win32Proj</Keyword>
24+
<ProjectGuid>{3b896a2b-6cd9-4261-a698-45c4285d6ff2}</ProjectGuid>
25+
<RootNamespace>EShop</RootNamespace>
26+
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
27+
</PropertyGroup>
28+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
29+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
30+
<ConfigurationType>Application</ConfigurationType>
31+
<UseDebugLibraries>true</UseDebugLibraries>
32+
<PlatformToolset>v143</PlatformToolset>
33+
<CharacterSet>Unicode</CharacterSet>
34+
</PropertyGroup>
35+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
36+
<ConfigurationType>Application</ConfigurationType>
37+
<UseDebugLibraries>false</UseDebugLibraries>
38+
<PlatformToolset>v143</PlatformToolset>
39+
<WholeProgramOptimization>true</WholeProgramOptimization>
40+
<CharacterSet>Unicode</CharacterSet>
41+
</PropertyGroup>
42+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
43+
<ConfigurationType>Application</ConfigurationType>
44+
<UseDebugLibraries>true</UseDebugLibraries>
45+
<PlatformToolset>v143</PlatformToolset>
46+
<CharacterSet>Unicode</CharacterSet>
47+
</PropertyGroup>
48+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
49+
<ConfigurationType>Application</ConfigurationType>
50+
<UseDebugLibraries>false</UseDebugLibraries>
51+
<PlatformToolset>v143</PlatformToolset>
52+
<WholeProgramOptimization>true</WholeProgramOptimization>
53+
<CharacterSet>Unicode</CharacterSet>
54+
</PropertyGroup>
55+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
56+
<ImportGroup Label="ExtensionSettings">
57+
</ImportGroup>
58+
<ImportGroup Label="Shared">
59+
</ImportGroup>
60+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
61+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
62+
</ImportGroup>
63+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
64+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
65+
</ImportGroup>
66+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
67+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
68+
</ImportGroup>
69+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
70+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
71+
</ImportGroup>
72+
<PropertyGroup Label="UserMacros" />
73+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
74+
<ClCompile>
75+
<WarningLevel>Level3</WarningLevel>
76+
<SDLCheck>true</SDLCheck>
77+
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
78+
<ConformanceMode>true</ConformanceMode>
79+
</ClCompile>
80+
<Link>
81+
<SubSystem>Console</SubSystem>
82+
<GenerateDebugInformation>true</GenerateDebugInformation>
83+
</Link>
84+
</ItemDefinitionGroup>
85+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
86+
<ClCompile>
87+
<WarningLevel>Level3</WarningLevel>
88+
<FunctionLevelLinking>true</FunctionLevelLinking>
89+
<IntrinsicFunctions>true</IntrinsicFunctions>
90+
<SDLCheck>true</SDLCheck>
91+
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
92+
<ConformanceMode>true</ConformanceMode>
93+
</ClCompile>
94+
<Link>
95+
<SubSystem>Console</SubSystem>
96+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
97+
<OptimizeReferences>true</OptimizeReferences>
98+
<GenerateDebugInformation>true</GenerateDebugInformation>
99+
</Link>
100+
</ItemDefinitionGroup>
101+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
102+
<ClCompile>
103+
<WarningLevel>Level3</WarningLevel>
104+
<SDLCheck>true</SDLCheck>
105+
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
106+
<ConformanceMode>true</ConformanceMode>
107+
</ClCompile>
108+
<Link>
109+
<SubSystem>Console</SubSystem>
110+
<GenerateDebugInformation>true</GenerateDebugInformation>
111+
</Link>
112+
</ItemDefinitionGroup>
113+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
114+
<ClCompile>
115+
<WarningLevel>Level3</WarningLevel>
116+
<FunctionLevelLinking>true</FunctionLevelLinking>
117+
<IntrinsicFunctions>true</IntrinsicFunctions>
118+
<SDLCheck>true</SDLCheck>
119+
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
120+
<ConformanceMode>true</ConformanceMode>
121+
</ClCompile>
122+
<Link>
123+
<SubSystem>Console</SubSystem>
124+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
125+
<OptimizeReferences>true</OptimizeReferences>
126+
<GenerateDebugInformation>true</GenerateDebugInformation>
127+
</Link>
128+
</ItemDefinitionGroup>
129+
<ItemGroup>
130+
<ClCompile Include="E-Shop.cpp" />
131+
</ItemGroup>
132+
<ItemGroup>
133+
<ClInclude Include="Admin.h" />
134+
<ClInclude Include="Customer.h" />
135+
<ClInclude Include="Database.h" />
136+
<ClInclude Include="Product.h" />
137+
<ClInclude Include="Products.h" />
138+
</ItemGroup>
139+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
140+
<ImportGroup Label="ExtensionTargets">
141+
</ImportGroup>
142+
</Project>

E-Shop/E-Shop.vcxproj.filters

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="Kaynak Dosyalar">
5+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6+
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7+
</Filter>
8+
<Filter Include="Üst Bilgi Dosyaları">
9+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10+
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
11+
</Filter>
12+
<Filter Include="Kaynak Dosyaları">
13+
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
14+
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
15+
</Filter>
16+
</ItemGroup>
17+
<ItemGroup>
18+
<ClCompile Include="E-Shop.cpp">
19+
<Filter>Kaynak Dosyalar</Filter>
20+
</ClCompile>
21+
</ItemGroup>
22+
<ItemGroup>
23+
<ClInclude Include="Customer.h">
24+
<Filter>Kaynak Dosyalar</Filter>
25+
</ClInclude>
26+
<ClInclude Include="Admin.h">
27+
<Filter>Kaynak Dosyalar</Filter>
28+
</ClInclude>
29+
<ClInclude Include="Database.h">
30+
<Filter>Kaynak Dosyalar</Filter>
31+
</ClInclude>
32+
<ClInclude Include="Products.h">
33+
<Filter>Kaynak Dosyalar</Filter>
34+
</ClInclude>
35+
<ClInclude Include="Product.h">
36+
<Filter>Kaynak Dosyalar</Filter>
37+
</ClInclude>
38+
</ItemGroup>
39+
</Project>

E-Shop/E-Shop.vcxproj.user

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup />
4+
</Project>

0 commit comments

Comments
 (0)