Oops Practical
Oops Practical
CHAPTER 1
1. INTRODUCTION
STC/SPRT/CW/2022 Page 1
Super Market In C++
STC/SPRT/CW/2022 Page 2
Super Market In C++
CHAPTER 2
SUPER MARKET SYSTEM
This system can be implemented to any shop in the locality or to multinational branded
shops having retail outlet chains. The system recommends a facility to accept the orders
24*7 and a home delivery system which can make customers happy. If shops are providing
an online portal where their customers can enjoy easy shopping from anywhere, the shops
won’t be losing any more customers to the trending online shops such as flipcart or ebay.
Since the application is available in the Smartphone it is easily accessible and always
available.
Study of System :-
The system after careful analysis has been identified to be presented with the
following modules and roles.The modules involved are:
Administrator
Users
Administrator :
The administrator is the super user of this application. Only Admin have access into this
admin page. Admin may be the owner of the shop. The administrator has all the
information about all the users and about all products.
Most importantly, they ensure a safe and efficient user experience. This may include
implementing security protocols, modifying programs, creating backups, resolving
software problems, updating content.
STC/SPRT/CW/2022 Page 3
Super Market In C++
Mange Products:
Add product:
The shopping cart project contains different kind of products. The products
can be classified into different categories by name. Admin can add new
products into the existing system with all its details.
Delete product:
Administrator can delete the products based on the stock of that particular
product.
View product:
Admin will have a list view of all the existing products. He can also search
for a particular product by name.
STC/SPRT/CW/2022 Page 4
Super Market In C++
CHAPTER 3
TECHNOLOGY USED
What is C++?
Some computer languages are written for a specific purpose. Like, Java was initially
devised to control toasters and some other electronics. C was developed for
programming OS. Pascal was conceptualized to teach proper programming
techniques. But C++ is a general-purpose language. It well deserves the widely
acknowledged nickname “Swiss Pocket Knife of Languages.”
Characteristics
Features of C++
C++ is an upgraded version of C programming. The main idea behind creating C++
programming was to add object orientation to the C programming language. The
major upgradations are object-oriented programming methodology, namespace
feature, operator overloading, error & exception handling. The motivation behind
object-oriented programming is to try to see the whole world in the form of classes
& objects.
STC/SPRT/CW/2022 Page 5
Super Market In C++
o Object Oriented
o Simple
o Platform Dependent
o Mid-level programming language
o Structured programming language
o Rich Library
o Memory Management
o Powerful & Fast
o Pointers
o Compiler based
o Syntax based language
Almost all the programs and systems that you use or a part of their codebase is
written either in C or C++. Be it Windows, a web browser, your favorite game, or a
video editing software, the uses of C++ can be found in almost all applications
today. Here are some interesting areas where C++ is popularly used.
STC/SPRT/CW/2022 Page 6
Super Market In C++
CHAPTER 4
CODE OF SUPER MARKET
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <exception>
#include <iostream>
#include <fstream>
#include <iterator>
#include <memory>
#include <ostream>
#include <string>
class shopping
{
private:
int pcode;
float price;
float dis;
string pname;
public:
void menu();
void administrator();
void add();
void buyer();
void edit();
void remov();
void list();
void receipt();
};
STC/SPRT/CW/2022 Page 7
Super Market In C++
switch (choice)
{
case 1:
cout << "Please Login \n";
if (email=="khizar.shah01@gmail.com" &&
password=="rootroot") {
administrator();
}
else {
/* if (email!="khizar.shah01@gmail.com") {
cout << "Invalid Email" << endl;
}
if (password!="rootroot") {
cout << "Invalid Password" << endl;
}*/
case 2:
{
buyer();
}
case 3:
{
exit(0);
}
default:
{
cout << "Select valid option";
}
}
STC/SPRT/CW/2022 Page 8
Super Market In C++
goto m;
void shopping::administrator()
{
m:
int choice;
switch (choice) {
case 1:
add();
break;
case 2:
edit();
break;
case 3:
remov();
break;
case 4:
menu();
break;
default:
cout << "Select right option";
}
goto m;
}
void shopping::buyer()
{
m:
int choice;
STC/SPRT/CW/2022 Page 9
Super Market In C++
switch (choice) {
case 1:
receipt();
break;
case 2:
menu();
break;
default:
cout << "\n Invalid option";
goto m;
}
void shopping::add()
{
m:
fstream data;
int c;
int token=0;
float p;
float d;
string n;
data.open("database.txt",ios::in);
if(!data)
{
data.open("database.txt",ios::app|ios::out);
data<<" "<<pcode<<" "<<pname<<" "<<price<<" "<<dis<<"\n";
data.close();
}
else
{
data>>c>>n>>p>>d;
while (!data.eof())
{
if(c ==pcode)
{
token++;
}
data>>c>>n>>p>>d;
STC/SPRT/CW/2022 Page 10
Super Market In C++
}
data.close();
if(token==1)
goto m;
else
{
data.open("database.txt",ios::app|ios::out);
data<<" "<<pcode<<" "<<pname<<" "<<price<<" "<<dis<<"\n";
data.close();
}
}
cout << "\n\n\t Record inserted!";
}
data.open("database.txt",ios::in);
if(!data)
{
cout<<"\n\t File doesn't exit \n";
}
else {
data1.open("database1.txt",ios::app|ios::out);
data>>pcode>>pname>>price>>dis;
while(!data.eof())
{
if(pkey==pcode)
{
cout <<"\n\tProduct new code :";
cin >>c;
cout <<"\n\tName of the product :";
cin >>n;
cout <<"\n\tPrice :";
cin >>p;
cout <<"\n\tDiscount :";
cin >>d;
STC/SPRT/CW/2022 Page 11
Super Market In C++
}
else {
data1<<" "<<pcode<<" "<<pname<<" "<<price<<"
"<<dis<<"\n";
}
data>>pcode>>price>>pname>>dis;
}
data.close();
data1.close();
remove("database.txt");
rename("database1.txt","database.txt");
if (token==0) {
cout << "\n\t Record not found !";
}
}
}
void shopping::remov()
{
fstream data,data1;
int pkey;
int token=0;
cout <<"\n\tDlete product";
cout <<"\n\tProduct code :";
cin >> pkey;
data.open("database.txt",ios::in);
if(!data){
cout << "\n File doesnt exit !";
}
else {
data1.open("database1.txt",ios::app|ios::out);
data>>pcode>>pname>>price>>dis;
while (!data.eof()) {
if (pcode==pkey) {
cout <<"\n\tProduct Delete succesfully";
token++;
}
else{
data1<<" "<<pcode<<" "<<pname<<" "<<price<<" "<<dis<<"\
n";
}
data>>pcode>>pname>>price>>dis;
}
data.close();
data1.close();
remove("database.txt");
rename("database1.txt","database.txt");
if(token==0)
STC/SPRT/CW/2022 Page 12
Super Market In C++
{
cout <<"\n\t Record not found!";
}
}
void shopping::receipt()
{
fstream data;
int arrc[100];
int arrq[100];
char choice;
int c=0;
float amount=0;
float dic=0;
float total=0;
list();
cout <<"\n-------------------------------\n";
cout <<"\n Please place the order \n";
cout <<"\n-------------------------------\n";
do {
m:
cout <<"\t Enter product code :";
cin >> arrc[c];
STC/SPRT/CW/2022 Page 13
Super Market In C++
}
data.close();
}
cout <<"\n\t\t______________";
cout <<"\n Total amount :"<<total;
int main()
{
shopping s;
s.menu();
return 0;
STC/SPRT/CW/2022 Page 14
Super Market In C++
CHAPTER 5
SCREENSHOT OF PROGRAM
Home interface
Administrator
STC/SPRT/CW/2022 Page 15
Super Market In C++
Buyer Interface
STC/SPRT/CW/2022 Page 16
Super Market In C++
REFERENCES
1. https://www.geeksforgeeks.org/
2. https://www.javatpoint.com/
3. https://www.wikipedia.org/
STC/SPRT/CW/2022 Page 17