C++ Code For Shopping Mall
C++ Code For Shopping Mall
C++ Code For Shopping Mall
CERTIFICATE OF ORIGINALITY ACKNOWLEDGEMENT ABOUT THE PROJECT SYSTEM REQUIREMENTS HEADER FILES VARIABLE DESCRIPTION FUNCTION DESCRIPTION LOGIC DIAGRAM SOURCE CODE OUTPUT SCREENS BIBLIOGRAPHY
3 4 5 6 7 8 10 11 12-28
29-38
39
PG 3
This is to certify that this project work is submitted by Arka roy to the COMPUTER department, Kendriya Vidyalaya Garden Reach, Kolkata.
It was carried out by him under the guidance & supervision OF RANJITA SARKAR MONDAL, head of computer science department during academics Year 2013-2014. Signature of TEACHER
PG 4
I wish to express my deep gratitude and sincere thanks To Principal, Mr. VENOGOPAL, Kendriya Vidyalaya Garden Reach school, Kolkata for his encouragement and for all Facilities that he provided for this project work. I sincerely appreciate this magnanimity by taking me into His fold for which I shall remain indebted to him. I extend my hearty thanks to Mrs. RANJITA SARKAR, Computer Science HOD, who guided me to the successful Completion of this project. I take this opportunity to Express my deep sense of gratitude for her invaluable Guidance, constant encouragement, constructive comments, Sympathetic attitude and immense motivation, Which has sustained my efforts at all stages Of this project work. I am also thankful to my group members Who have helped in each step of my Project work? I can't forget to offer my sincere thanks to my Classmates who helped me to carry out this project work Successfully & for their valuable advice & support, Which I received from them time to time.
ARKA ROY
PG 5
The project comprises of a shopping mall and is developed on the C++ platform so that the program can be used for account management and online shopping. Here you can shop to your hearts content. Our program allows you to shop from different stores as it brings you a Daily Market, a Bookstore and a Gadget shop all under one roof. It even provides you with the feature of paying your bill online or saving it as a wish list. It also provides flexible paying option via VISA or COD. It has a special feature of displaying the previous bills along with the current bill.
Technical Information
The logic of this program is based on selective delimitation by get line function in various files. Firstly we extract the categories by locating the + sign in our storage file. Then the pointer is taken right to that category number by delimiting the pointers position through an iterative structure for the number of lines which equals to the choice number. For arts and diagrams, ASCII arts has been implemented from the file.
PG 6
PG 7
PG 7
1.) CONIO.H TO USE CLEARSCREEEN AND GETCH FUNCTION FORFORMATTING IN PROGRAM 2.) IOSTREAM.HFOR USING INPUT OUTPUT PRE-DEFINED STREAM FUNCTIONS IN THE PROGRAM 3.) STRING.HTO USE STRING RELATED FUNCTIONS IN THE PROGRAM 4.) STDIO.HTO USE GETS() AND PUTS() FUNCTION FOR STRING INPUT 5.) FSTREAM.H FOR USING INPUT AND OUTPUT FILES RELATED OPERATION IN THE PROGRAM 6.) STDLIB.H TO USE STANDARD LIBRARY FUNCTIONS LIKE SRAND IN THE PROGRAM 7.) PROCESS.H - FOR USING INSTANTANEOUS EXIT FUNCTION IN THE PROGRAM 8.) TIME.H- FOR INITIALIZING SRAND WITH RANDOM NUMBER GENERATED BY THE SYSTEM INTERNAL CLOCK
PG 8
Function name
Name
Type
Use
ch i d q
read from loading.txt counter variable to manipulate waiting period used in delay loop
billing_centre() billing_centre() billing_centre() billing_centre() billing_centre() billing_centre() billing_centre() billing_centre() billing_centre() billing_centre() billing_centre() billing_centre()
char(array) char(array) char(array) char(array) char(array) long long int int int char(2-d array) char array
holds the name of the customer holds the district of the customer holds the state of the customer holds the area of the customer holds the visa card no. of the customer holds pin number of customers location holds order id accept choice for bank loop variable switch control variable hold bank names delimiter in user form
Function name
frontpage() readdata() readdata() readdata() readdata() readdata() readdata() readdata() readdata() readdata() i,j l
Name int
int
Type
Use
PG 9
loop variable to design frontpage Read length of the extracted line from file of the calling store Extract price from variable l To put the get point to the default position after looping Stores bill of instantaneous store To accept the value for order confirmation Accept the user code Code part of txt file in int form To accept choice from category list Looping variable
readdata()
readdata() readdata() readdata() readdata() main() main() main() main()
quan
menu line word ch1 z p nm ch
int
char array char array char array char array int int char array char
PG 10
FUNCTION DESCRIPTION
void
frontpage
void
display
Used to print the categories page of western gardens by importing form file catagories.txt.
void
billing centre
void
readdata
Extract the product from stored text file as per user choice and store details in dynamically allocated file. Used to switch between different stores and implement operations accordingly.
-void
main
PG 11
PG 12
/*................................................................................ LIST OF ALL THE HEADER FILES USED ..................................................................................*/ #include <conio.h> #include <iostream.h> #include <string.h> #include <stdio.h> #include <fstream.h> #include <stdlib.h> #include <process.h> #include <time.h> //-------------------------------- MACROS----------------------------------------#define pr "*=================================* /*_____________________________________________________ THE DESIGN CLASS _______________________________________________________*/ class design { //DECLARATION OF CLASS VARIABLE public: long double total; //global variable
PG 13
// CONSTRUCTOR IMPLEMENTATION design() { total=0; } /* ============================================= FUNCTION PROTOTYPES ============================================= */ void display(); void frontpage(); void readdata(ifstream&,ifstream&,ifstream&,fstream&); void blink(); void billing_centre(); }; /* ============================================= FUNCTION DEFINATIONS ============================================= */
void design::blink() { system("cls"); //VARIABLE DECLARATIONS ifstream f2; char ch[1000]; int i=0,j; long len=i,d=0; f2.open("loading.txt",ios::in);
PG 14
while(f2) { ch[i]=(char)f2.get(); i++; } for(i=1;i<=100;i++) { for(j=0;j<=len;j++) { cout<<ch[j]; while(d>10000)//delay loop d++; d=0; } cout<<endl<<endl; system("cls"); } f2.close(); }
//CALCULATION OF ORDER ID
PG 15
//ASSIGNMENT OF BANK NAMES char bank[7][40]={"State Bank of India","Union Bank of India", "Punjab National Bank","Allahabad bank","UCO bank","Axis bank"}; f1.open("Payment.txt",ios::out|ios::app); //INPUTS FOR PROCESSING BILL a:system("cls"); //DEFINING LABEL cout<<"\n\n\t\tUSER DETAILS\n\n"; cout<<"\n\n"<<pr<<"\n\n\t NAME: ";gets(name);cout<<"\n\n"<<pr; cout<<"\n\n"<<pr<<"\n\n\t STATE: ";gets(state);cout<<"\n\n"<<pr; cout<<"\n\n"<<pr<<"\n\n\t DISTRICT: ";gets(district);cout<<"\n\n"<<pr; cout<<"\n\n"<<pr<<"\n\n\t AREA: ";gets(area);cout<<"\n\n"<<pr; cout<<"\n\n"<<pr<<"\n\n\t PHONE NUMBER: ";cin>>pno;cout<<"\n\n"<<pr; cout<<"\n\n"<<pr<<"\n\n\t PIN CODE: "; //ERROR ANALYSIS FOR PIN CODE for(i=0;i<=5;i++) { pin[i]=(char)getch(); cout<<pin[i]; if(pin[i]>=48 && pin[i]<=57) continue; else { cout<<"\n\n"<<pr;
cout<<"\n\nSorry entered wrong please fill the form PG 16 correctly";getch(); strcpy(pin,"");strcpy(name,"");strcpy(state,"");strcpy(district,""); strcpy(district,"");getch(); goto a; } } cout<<"\n\n"<<pr;
//SWITCHING CHOICE switch(c) { //CASH ON DELIVERY OPTION case 1: blink(); cout<<"\n\n\tYOUR ORDER HAS BEEN PROCESSED" <<"\n\n\tDELIVERY DURATION: 7 DAYS "; cout<<"\n\tORDER ID: "<<id; cout<<"\n\n\n\t*********THANK YOU FOR SHOPPING*************"; break; // VISA case 2: again:system("cls");
blink(); cout<<"\n\tENTER THE BANK NAME \n\n"; cout<<"\n\n\t1.STATE BANK OF INDIA\n"; cout<<"\n\n\t2.UNION BANK OF INDIA\n"; cout<<"\n\n\t3.PUNJAB NATIONAL BANK\n"; cout<<"\n\n\t4.ALLAHABAD BANK\n"; cout<<"\n\n\t5.UCO BANK\n"; cout<<"\n\n\t6.AXIS BANK \n\n\t"; cin>>cb; //ERROR ANALYSIS FOR BANK SELECTION if((cb>6)||(cb<0)) //if condition does not match goto again; system("cls");
PG 17
blink();//card details cout<<"\n\n\t"<<bank[cb-1]<<"\n\n"; cout<<"\n\tEnter your card number(16 digit): "; for(i=0;i<=15;i++) { cno[i]=(char)getch(); if((i<=12 && i>0) && (i==3 || i==7 || i==11)) cout<<cno[i]<<"-"; else cout<<cno[i]; } //ACCEPTING SECURED BANK DETAILS (PASSWORD MODE) cout<<"\n\n\tEnter your CVV number(3 digit): "; for(m=0;m<=2;m++) { getch();cout<<"*"; } cout<<"\n\n\tEnter your password(8-digit): " ;
PG 18
cout<<"\n\n\tYOUR ORDER HAS BEEN PROCESSED"; cout<<"\n\tRs."<<total<<" HAS BEEN DEDUCTED FROM YOUR <<ACCOUNT"; cout<<"\n\tORDER ID: "<<id; cout<<"\n\n\n\t*********THANK YOU FOR SHOPPING*************"; break;
default: cout<<"\n\tWRONG CHOICE"; } //PRINTING DETAILS TO FILE f1<<"\n PAYMENT DETAILS\n"; f1<<"\n\tNAME: "<<name; f1<<"\n\tSTATE: "<<state; f1<<"\n\tDISTRICT: "<<district; f1<<"\n\tAREA: "<<area;
f1<<"\n\tPIN: "<<pin; f1<<"\n\tPHONE NUMBER : "<<pno; if(c==2) { f1<<"\n\tPAYMENT MODE: VISA"; f1<<"\n\tBANK NAME: "<<bank[cb-1]; f1<<"\n\tCARD NUMBER: "; for(m=0;m<15;m++) { if((m>=0&&m<=1)||(m>=13 && m<=15)) f1<<cno[m]; else f1<<"x"; } } else { f1<<"\n\tPAYMENT MODE: COD"; f1<<"\n\tTOTAL BILL: "<<total; f1<<"\n\tORDER ID: "<<id;
PG 19
f1<<"\n\t"<<pr; f1.close();
} }
void design::frontpage()
PG 20
void design::display() { system("cls"); ifstream obj; obj.open("catagories.txt"); while(!obj.eof()) cout<<(char)obj.get(); obj.close(); cout<<"\n\t PLEASE ENTER YOUR CHOICE [single digit] \t"; } void design::readdata(ifstream& obj,ifstream& obj0,ifstream& fpage,fstream& obj1) { long price,pos ; int cnf,cd,code=0,cnum=-1,i,j,quan,l; //VARIABLE DECLARATIONS
long double sum=0; char menu[1500],line[1500],word[6],ch1[3],x[3000]; //DISPLAYING FRONTPAGE OF EACH INDIVIDUAL STORE system("cls");
PG 21
// EXTRACTION UPTO CATEGORY FROM THE INPUT FILE obj.getline(x,3000,'+'); pos=obj.tellg(); STORE IT //ASSIGN THIS POSITION AS DEFAULT AND
//PRINTING TABULAR BILL TO FILE obj1<<"\n\tCODE\tNAME\t\t\t\tUNIT-PRICE\tQUANTITY\n"; //SELECTION IN CATEGORY AND LOOPING IT while(cnum!=0) { //PRINTING THE CATEGORY FROM FILE TO SCREEN system("cls"); puts(x); cout<<"\n\t Please Enter the Category Number (0 to Exit) \n\n\t "; cin>>cnum; if(cnum==0) break; //ERROR ANALYSIS FOR CATEGORY NUMBER if(cnum>6) { cout<<"\n\t Sorry Wrong Catagory !! Kindly Visit the store once again "; break; } //SHIFTING POINTER TO DEFAULT LOCATION IN INPUT FILE
obj.seekg(pos);
PG 22
//EXTRACTING THE CATEGORY DETAILS OF USER'S CHOICE for(i=1;i<cnum;i++) obj.getline(menu,1500,'#'); obj0.seekg(obj.tellg()); obj.getline(menu,1500,'#'); //CODE FOR MUTIPLE ORDERS IN CATEGORY PRODUCTS while(!obj0.eof()) { system("cls"); cout<<"\n\t Info : Press The Code To Order "; cout<<"\n\t : Press 0 - To Go to Catagories Menu \n\n"; //PRINTING THE CATEGORY DETAILS AND ASKING CHOICE cout<<menu<<"\n\t"; cout<<"\n\t|_CODE_|:-> \t"; //asking code cin>>code; if(code==0) break; // TO GOTO CATEGORY MENU obj0.seekg(pos); //CHANGING POINTER POSITION TO DEFAULT
//code is extracted
PG 23
if(cd==code) { l=strlen(line); cout<<"\n\t|_QUANTITY_|:-> "; //asking quantity cin>>quan; cout<<"\n\t Ordered :"; cout<<"\n\n\tCODE\tNAME\t\t\t\tUNIT-PRICE\tQUANTITY \n\n\t"; cout.write(line,l);cout<<"\t\t"<<quan; //CONFIRMATION OF ORDER cout<<"\n\n\n\t TO CONFIRM ORDER PRESS 1\n\t "; cin>>cnf; if(cnf!=1) { cout<<"\n\t ORDER CANCELLED "; getch(); break; } for(j=0;j<5;j++) word[j]=line[l-5+j]; price=quan*atoi(word); sum=sum+price; total=total+sum; obj1<<"\n\t"; obj1.write(line,l);obj1<<"\t\t"<<quan; cout<<"\n\t ORDER CONFIRMED "; getch(); break; } } if(code!=cd) //ERROR ANALYSIS FOR ITEM CODE
PG 24
{ cout<<"\n\t Sorry Wrong Code Entered Please Visit the store once again"; getch(); break ; } } //CONDITION FOR SUCCESSFUL ORDER if(code!=0) break; } if(sum==0) obj1<<"\n\t NOTHING IS BOUGHT FROM THIS STORE "; obj1<<"\n\n\t Your Total Bill From This Store : "<<sum; } /*___________________________________________________ THE MAIN FUNCTION _______________________________________________________*/ void main() { int z=0,p=1; //variables char nm[20],ch; ifstream obj,obj0; fstream obj1; //CONCEPT IMPLEMENTATION FOR DYNAMIC FILE NAME ALLOCATION cout<<"\n\t Please view in full screen \n\n\t Enter Username :\n\n\t "; gets(nm); strcat(nm,".txt"); //file object declarations
obj1.open(nm,ios::app);
PG 25
//FRONTPAGE DESIGN FUNCTION system("cls"); design d; //frontpage design d.frontpage(); //INTIALIZING THE OUTPUT FILE WITH MALL NAME obj1<<"\n\n\t"<<pr; obj1<<"\n\n\n\t\t THE WESTERN GARDENS SHOPPING ARCADE \n\n"; //storing info in file obj1<<"\n\t\t YOU VISITED THE FOLLOWING STORES : \n\n"; //LOOPING FOR SWITCHING STORES while(p==1) { //DISPLAY OF THE IN-THE-MALL MENU d.display(); cin>>ch; // asking the choice switch(ch) { case '1' : { system("cls"); ifstream abt; abt.open("about.txt"); while(!abt.eof()) cout<<(char)abt.get(); getch(); break; } case '2' : //electronics
{ ifstream store; store.open("gstore.txt"); obj0.open("electronics.txt"); obj.open("electronics.txt"); obj1.close(); fstream obj1; obj1.open(nm,ios::app); obj1.seekg(z); obj1<<"\n\n\t GADGETOMANIA\n"; d.readdata(obj,obj0,store,obj1); z=obj1.tellp(); store.close(); break; }
PG 26
case '3' : //market { ifstream store; store.open("mstore.txt"); obj0.open("market.txt"); obj.open("market.txt"); obj1.close(); fstream obj1; obj1.open(nm,ios::app); obj1.seekg(z); obj1<<"\n\n\t THE WESTERN MARKETS\n"; d.readdata(obj,obj0,store,obj1); z=obj1.tellp(); store.close(); break; }
//book store
store.open("bstore.txt"); obj0.open("books.txt"); obj.open("books.txt"); obj1.close(); fstream obj1; obj1.open(nm,ios::app); obj1.seekg(z); obj1<<"\n\n\t A PAGE AND INK \n"; d.readdata(obj,obj0,store,obj1); z=obj1.tellp(); store.close(); break;
PG 27
} case '5' : //bill payment { int mode; system("cls"); if(d.total==0) { cout<<"\n\t Sorry Your Cart is Empty";break; } obj1.close(); ifstream obj1; obj1.open(nm); while(obj1) cout<<(char)obj1.get(); cout<<"\n\n\t YOUR TOTAL BILL FROM ALL THE STORES => " <<d.total<<"\n\n\n\t"<<pr; cout<<"\n\n\t Please 1 to Proceed Paying Bill \n" <<"\t\t2 to save your bill in Wishlist mode and exit\n\t "; cin>>mode; if(mode==2) { cout<<"\n\t WISHLIST SAVED IN HARD-DISK"; }
PG 28
case '6' : { exit(0); } default : { cout<<"\n\t Wrong Choice .. Press any Key to continue Again"; getch(); system("cls"); break; } } //CLOSING THE FILES obj0.close(); obj1.close(); obj.close();
cout<<"\n\n\t Press 1- WESTERN GARDENS CATALOGUE" <<"\n\t OR ANY OTHER KEY TO EXIT FROM MALL\n\t "; cin>>p; if(p!=1) exit(0); } }
PG 29
PG 30
PG 31
PG 32
PG 33
PG 34
PG 35
PG 36
PG 37
PG 38
PG 39
ASCII ARTS:
WWW.NETWORK-SCIENCE.DE WWW.PATORJK.COM
LOGO :
WWW.FLAMINGTEXT.COM WWW.COOLTEXT.COM