• No results found

C++ code for Shopping Mall

N/A
N/A
Protected

Academic year: 2021

Share "C++ code for Shopping Mall"

Copied!
39
0
0

Loading.... (view fulltext now)

Full text

(1)

(2)

1. CERTIFICATE OF ORIGINALITY 3

2

ACKNOWLEDGEMENT

4

3. ABOUT THE PROJECT

5

4. SYSTEM REQUIREMENTS

6

5.

HEADER FILES

7

6.

VARIABLE DESCRIPTION

8

7. FUNCTION DESCRIPTION

10

8.

LOGIC DIAGRAM

11

9. SOURCE CODE

12-28

10.

OUTPUT SCREENS

29-38

11. BIBLIOGRAPHY

39

(3)

It was carried out by him under the

guidance & supervision OF RANJITA

SARKAR MONDAL, head of computer

science department during academics

Year

2013-2014.

This is to certify that this

project work is submitted by

Arka roy to the COMPUTER

department, Kendriya Vidyalaya

Garden Reach, Kolkata

.

Signature of TEACHER

(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

(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 heart’s 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 pointer’s 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.

(6)

Minimum System

Requirements:

Processor

Intel Pentium III or above

Hard-disk Space-

– 20 MB

RAM

– 512 mb or more

Platform

– Windows XP,7 or 8

Software

: Borland Turbo C++ 5.02

(7)

PG 7

1.) CONIO.H –

TO USE CLEARSCREEEN AND GETCH FUNCTION FORFORMATTING IN PROGRAM

2.) IOSTREAM.H-

FOR USING INPUT OUTPUT PRE-DEFINED STREAM FUNCTIONS IN THE PROGRAM

3.) STRING.H-

TO USE STRING RELATED FUNCTIONS IN THE PROGRAM

4.) STDIO.H-

TO 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

(8)

Function name Name Type Use

blink() ch char read from loading.txt

blink() i int counter variable

blink() d long to manipulate waiting period

blink() q long double used in delay loop

billing_centre() name char(array) holds the name of the customer

billing_centre() district char(array) holds the district of the customer

billing_centre() state char(array) holds the state of the customer

billing_centre() area char(array) holds the area of the customer

billing_centre() cno char(array) holds the visa card no. of the customer

billing_centre() pin long holds pin number of customers

location

billing_centre() id long holds order id

billing_centre() cb int accept choice for bank

billing_centre() m int loop variable

billing_centre() c int switch control variable

billing_centre() bank char(2-d array) hold bank names

billing_centre() l char array delimiter in user form

(9)

Function name Name Type Use

frontpage() i,j int loop variable to design frontpage readdata() l int Read length of the extracted line

from file of the calling store readdata() price long Extract price from variable l

readdata() pos long To put the get point to the default position after looping

readdata() sum long Stores bill of instantaneous store readdata() cnf int To accept the value for order

confirmation

readdata() code int Accept the user code

readdata() cd int Code part of txt file in int form readdata() cnum int To accept choice from category list readdata() i,j int Looping variable

readdata() quan int Accept quantity of each product readdata() menu char array Stores instantaneous category list readdata() line char array Extract the line store it from

category

readdata() word char array Extract price from the line and store it

readdata() ch1 char array To extract code from the line char form

main() z int Put get pointer after each bill in output file

main() p int While loop control variable main() nm char array Store instantaneous dynamic

output file name

main() ch char Switch control variable for store selection

(10)

RETURN TYPE

FUNCTION NAME

FUNCTION DESCRIPTION

void blink Delay execution by printing “Loading”(using

delay loop).

void frontpage Print the designed frontpage using file

“mall.txt”.

void display Used to print the categories page of western

gardens by importing form file “catagories.txt”.

void billing centre Store the user transaction details in file

“payment.txt”.

void readdata Extract the product from stored text file as per

user choice and store details in dynamically allocated file.

-void main Used to switch between different stores and

implement operations accordingly.

(11)
(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

(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 13

(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(); } void design::billing_centre() { char name[20],district[20],state[20],area[20],cno[16],pin[6]; long id,pno; int cb=0,m,c,i;

ofstream f1; //outstream object ifstream f3; //input-stream object //CALCULATION OF ORDER ID

(15)

srand (time(NULL));

id=rand()%9999999+1000000; //generating random number //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;

(16)

cout<<"\n\nSorry entered wrong please fill the form correctly";getch(); strcpy(pin,"");strcpy(name,"");strcpy(state,"");strcpy(district,""); strcpy(district,"");getch(); goto a; } } cout<<"\n\n"<<pr; getch(); system("cls");blink();

cout<<"\n\n\t\t\tENTER MODE OF PAYMENT:\n\n\n\t"

<<"1.CASH ON DELIVERY(COD)\n\n\t2.VISA\n\n\t"; cin>>c; //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"); PG 16

(17)

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");

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): " ;

(18)

for(m=0;m<=7;m++) { getch();cout<<"*"; } cout<<endl; system("cls"); blink();

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; PG 18

(19)

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;

f1<<"\n\t"<<pr; f1.close(); } } void design::frontpage() PG 19

(20)

{ ifstream obj; obj.open("mall.txt"); while(!obj.eof()) cout<<(char)obj.get(); obj.close(); getch(); } 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");

(21)

while(!fpage.eof())

cout<<(char)fpage.get(); getch(); system("cls");

// EXTRACTION UPTO CATEGORY FROM THE INPUT FILE obj.getline(x,3000,'+');

pos=obj.tellg(); //ASSIGN THIS POSITION AS DEFAULT AND STORE IT

//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

(22)

obj.seekg(pos);

//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

//============================================== //MATCHING USER CODES WITH CODES IN INPUT FILES

//============================================== while(!obj0.eof())

{

obj0.getline(line,1500,'.'); for(int j=0;j<3;j++)

ch1[j]=line[j]; //code is extracted

(23)

cd=atoi(ch1) ;

//EXTRACTING THE ITEM LINE FROM FILE 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

(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

(25)

obj1.open(nm,ios::app); //output object declaration //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 PG 25

(26)

{

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; } 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;

}

case '4' : //book store {

ifstream store;

(27)

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;

}

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"; }

(28)

else if(mode==1)

d.billing_centre(); else

cout<<"\n\t WRONG CHOICE !!"; break; } 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); }

}

(29)

(30)

.

(31)

(32)

(33)

(34)

(35)

(36)

(37)
(38)

(39)

ASCII ARTS:

WWW.NETWORK-SCIENCE.DE

WWW.PATORJK.COM

LOGO :

WWW.FLAMINGTEXT.COM

WWW.COOLTEXT.COM

PG 39

References

Related documents