THE CUBE: Antique Store

66

description

This is the project i made for my 12th grade. Using basic C++, I made this software (which i call 'The Cube') capable of handling operations ranging from displaying store items to money tracking.

Transcript of THE CUBE: Antique Store

Page 1: THE CUBE: Antique Store
Page 2: THE CUBE: Antique Store

This is to certify that

Neil Mathew, Roll No: _____ ,

has successfully completed his Project

under my guidance and has fulfilled

the requirements for the submission of this project.

Ms. Geetu Munjal,

_________________

CERTIFICATE

Page 3: THE CUBE: Antique Store

CONTENTS

S No: Name: Page No:

1 ACKNOWLEDGEMENT 1 [ 1 - 1 ]

2 INTRODUCTION 2 [ 1-2 ]

3 THE 6 FACES OF THE CUBE 3 [ 1–2 ]

4 FLOW CHART DIAGRAM 4 [ 1-4 ]

5 USER DEFINED FUNCTIONS 5 [ 1-1 ]

6 PROGRAM CODE 6 [ 1-17 ]

7 SAMPLE INPUT & OUTPUT 7 [ 1-33 ]

8 BIBLIOGRAPHY 8 [ 1-1 ]

9

SCOPE FOR FUTURE EXPANSION

9 [ 1-1 ]

Page 4: THE CUBE: Antique Store

1: [1]

ACKNOWLEDGEMENT

I am indebted to my computer teacher,

Ms Geetu Munjal

for her guidance and whole hearted support in the making of this project.

Page 5: THE CUBE: Antique Store

2:[1]

I call this software ‘THE CUBE’. This is mainly because of the fact that it performs 6 types of tasks. Three of them are general while the other three are user specific.

The Cube is made for 3 types of users:

A Customer, A Supplier and The Manager.

A more elaborate coverage of The Cube’s function can be seen in ‘THE 6 FACES OF THE CUBE”.

INTRODUCTION

This software is made to cover the processes associated with an Antique Store. Its applications extend to customers, suppliers, cashiers, managers

and other staff members alike.

Besides allowing us to view and search the items on sale, its main priority is maintaining a record of the transaction of money and items.

With a buy, an item is lost and its price is added to the store balance. Similarly, If the manager was to accept a Supplier’s offer,

that items asked price would be subtracted from the store balance and be added to the list of items on sale.

This allows the Store to have a constantly updated reference to check

the progress of the store.

Page 6: THE CUBE: Antique Store

2: [2]

INTRODUCTION

To make it implementable in the real world, I have ensured that:

(1) Data is stored in files and opened in binary mode for speed.

(2) The interface has been made interactive and user friendly.

(3) It has covered all possible threats to efficacy by means of Intensive Exception Handling like:

(i) Invalid Entries by User

(ii) An Advanced Search that is NOT case sensitive.

(iii) And many others like: Maintaining transfer of cash through sale and purchase of the store,

Maintaining Transfer of Data from Supplier Offer to Item On Sale, etc

Page 7: THE CUBE: Antique Store

3: [1]

THE LISTThis is a Tabular representation of the list of items on sale in the store. The following 4 entities are displayed here.

The Item number The Name The Age (in Years) The Cost

SPACING TOOL There is a function which is responsible for the tabular format of THE LIST.

1 THE HISTORY

2 This is a more detailed view of the items in THE LIST.

It not only gives the 4 entities in THE LIST but also shows the history of the item and its significance in the past.

However, only a limited number of items can be seen at a time.

THE SEARCH

3 This allows users to search for an item, making it much easier than going through the long list to find something specific.

The search allows us to narrow down the list by Providing Ranges in the Cost and Age A word search for Name and History.

THE 6 FACES OF THE CUBE

This is a more elaborate explanation of THE CUBE and the various tasks that it performs.

Page 8: THE CUBE: Antique Store

3: [2]

I AM A CUSTOMER

Once the money transfer is complete:

A bill for the user will be displayed. There will be an increase in the store balance. The item will be removed from THE LIST.

4 I AM A SUPPLIER

5 The user will have to enter the details of the item he wishes to sell including the price he is asking for it. This will be stored and decided later by the manager.

I AM THE MANAGER

6 This option is for the manager. Since this is restricted to the general public, it is password protected. The Manager has the most number of options. He can add, delete and edit an item on THE LIST. He can change the password and access the CUBE CASHIER.

THE 6 FACES OF THE CUBE

This is one of the 3 user specific options. If this is chosen, the user will be able to choose and buy the item of his choice.

CUBE CASHIER This is a money organizer for the store. When an item is sold or bought by the store, the balance increases and decreases accordingly.

This option is for those who have something to sell to the store.

When the manager accepts: The item will be added to the LIST. There will be a decrease in the store balance.

Page 9: THE CUBE: Antique Store

FLOW CHART DIAGRAM

STARTDISPLAY THE VARIOUS OPTIONS:

(1) THE LIST | (2) THE HISTORY | (3) THE SEARCH | | (4) I AM A CUSTOMER | (5) I AM A SUPPLIER | (6) I AM THE MANAGER

CHOOSE (Input Ch)

RESTART THE DO WHILE LOOP

42 1 3 5 6

IF CH=1

|| CH=2 || CH=3

|| CH=4 || CH=5

|| CH=6 || CH=0

Ch=1 Ch=2 Ch=3 Ch=4 Ch=5 Ch=6 ELSE

END

Ch=0

SHOW ERROR

MESSAGE

0

Page 10: THE CUBE: Antique Store

1 void view() SHOWS THE LIST OF ITEMS

void Space() PROVIDES TABULAR FORMAT

FOR THE LIST

void SORT_LIST() SORTS THE LIST ACCORDING

TO ASCENDING ITEMNO

2void viewHis()

SHOWS THE LIST OF ITEMS WITH HISTORY OF EACH

Call Call

Call Call

3

DISPLAYS THE VARIOUS OPTIONS

| PROVIDE RANGES IN (1) AGE (2) COST

| A WORD SEARCH FOR (3) NAME OF ITEM (4) HISTORY

CHOOSE (Input Ch)

IF CH=1 || CH=2

|| CH=3 || CH=4

ELSE

Ch=1 Ch=2 Ch=3

SHOW ERROR

MESSAGE

Ch=4

0

0

0

ASKS FOR

UPPER LIMIT & LOWER LIMIT

THEN DISPLAYS THE SEARCH

RESULTS

ASKS FOR

THE WORD TO SEARCH FOR

THEN DISPLAYS THE SEARCH

RESULTS

ASKS FOR

UPPER LIMIT & LOWER LIMIT

THEN DISPLAYS THE SEARCH

RESULTS

ASKS FOR

THE WORD TO SEARCH FOR

THEN DISPLAYS THE SEARCH

RESULTS

FLOW CHART DIAGRAM

Page 11: THE CUBE: Antique Store

5

SHOW

ASKS HOW MANY ITEMS THE SUPPLIER IS WILLIING TO SELL.

ENTER (Input num)

SHOW: ASKS FOR ITEM NO: TO BUY:

4

ENTER ITEMNO (INPUT CHK)

TRUE

IF

CHK COINCIDES WITH

EXISTING ITEM NO

FALSE

SHOW: ASKS WHETHER TO BUY MORE? (y/n)

ENTER (INPUT OK)

TRUE

IF OK = ‘Y’

|| OK= ‘y’

FALSE

SHOW: THE BILL OF ALL

ITEMS PURCHASED

0

SHOW: SHOW WHICH ALL

DETAILS OF ITEM IS REQUIRED:

IFnum LOOPS

ARE COMPLETED.

ENTER THE DETAILS

FALSE

FLOW CHART DIAGRAM

Page 12: THE CUBE: Antique Store

FLOW CHART DIAGRAM

6

DISPLAYS THE VARIOUS OPTIONS

| (1) CHANGE YOUR PASSWORD. | (2) ADD AN ITEM TO THE LIST.

| (3) DELETE AN ITEM ON THE LIST. | (4) EDIT AN ITEM ON THE LIST.

| (5) USE THE CUBE CASHIIER | (0) EXIT

SHOW “ENTER PASSWORD” SHOW

“WRONG PASSWORD”

IF PW == PASS

ENTER (Input PW)

FALSE

TRUECHOOSE (Input Ch)

IF CH=1

|| CH=2 || CH=3

|| CH=4 || CH=5

|| CH=0

ELSE

0

Ch=0

CHANGES THE STRING STORED IN

PASS OF CLASS

MANAGER WHICH

IS LATER STORED

INTO A DATAFILE.

Ch=1

void ADD()

ALLOWS MANAGER TO ADD

RECORDS/ITEMS FROM

(1) SUPPLIER (HIS ITEMS’S DETAILS ARE

SHOWN AND USER CAN

ACCEPT OR DECLINE THE

SUPPLIER’S OFFER )

(2) FROM MANAGER ( HE CAN ADD THE ITEMS

HIMSELF TO THE STORE )

void EDIT()

ACCORDING TO THE ITEM NO

INPUTTED, DETAILS CAN BE CHANGED

void DEL()

ACCORDING TO THE ITEM NO INPUTTED, ITEM & ITS DETAILS ARE DELETED. void CCASH()

ALLOWS USER TO

VIEW, DEPOSIT AND

WITHDRAW FROM HIS

STORES’ BALANCE

0

Ch=4

Ch=3

Ch=5

Ch=2

Page 13: THE CUBE: Antique Store

5: [1]

.

OTHERS

1 0

I AM THE MANAGER

1 6

I AM A SUPPLIER

1 5 I AM A CUSTOMER

1 4

THE SEARCH

1 3

THE HISTORY

1 2THE LIST

1 VOID VIEW() - DISPLAYS THE ITEMS IN TABULAR FORMAT

VOID VIEWHIS() - SHOWS THE HISTORY OF THE ITEM

VOID SEARCH() - FINDS AN ITEM BY SEARCHING FOR KEYWORDS IN NAME, AND RANGE IN AGE AND COST

VOID BUY() - ALLOWS USER TO BUY ITEMS ON THE LIST

VOID PW() – CHANGES PASSWORD TO ENTER THIS VOID CCASH() – CUBE CASHIER ALLOWING USER TO

DEPOSIT, WITHDRAW AND VIEW STORE’S BALANCE VOID EDIT() – EDITS INFO OF EXISTING ITEM IN LIST VOID ADD() – ADDS AN ITEM TO LIST (INDIRECTLY

FROM SUPPLIER OR DIRECTLY FROM MANAGER) VOID DEL() – DELETES AN EXISTING ITEM FROM LIST

VOID SELL() - ALLOWS USER TO SELL ITEMS TO STORE

VOID SPACE() – RESPONSIBLE FOR PROPER SPACING OF

STRINGS AND INTEGERS (FUNCTION OVERLOADING) INT FIND_IT() – FINDS THE POSITION OF THE ITEM IN

THE ARRAY BY COMPARING ITEM NUMBERS AND RETURNS IT VOID REMOVE_IT() – REMOVES THE ITEM FROM THE

LIST. BOTH DEL() AND BUY() CALLS THIS FUNCTION VOID SORT_LIST() – SORTS THE ITEMS IN THE LIST VOID ALL_IN() – WRITES ALL INFO INTO DATAFILE VOID ALL_OUT() – READS ALL INFO INTO PROGRAM

USER DEFINED FUNCTIONS

Page 14: THE CUBE: Antique Store

6: [1]

PROGRAM CODE

#include<fstream.h> #include<stdio.h> #include<string.h> #include<conio.h> #include<ctype.h> #include<dos.h> //SPACING TOOL OVERLOADED FUNCTIONS //For Strings: void Space(int n,char str[40],char sp=' ') { /* There is a fixed number of places(n), and after the string (str) is displayed, the remaining places are filled with spaces OR a char (sp). This allows the data to be shown more aligned. */ int i; cout.write(str,strlen(str)); int L=(n-strlen(str)); for(i=1; i<=L; i++) { cout<<sp; } } //For Unsigned Long: void Space(int n, unsigned long a) { /* Same concept as above BUT a different arrangement for Nos. From the fixed number of places(n), the number (a) is displayed at the end rather than the beginning as for strings. */ unsigned long i=a; int count=0; do { i=i/10; count++; } while(i>0); for(i=1; i<=(n-count); i++) putchar(' '); cout<<a; }

Page 15: THE CUBE: Antique Store

6: [2]

PROGRAM CODE

//For Integers. void Space(int n, int a) { int i=a; int count=0; do { i=i/10; count++; } while(i>0); for(i=1; i<=((n-count)); i++) putchar(' '); cout<<a; }

Page 16: THE CUBE: Antique Store

6: [3]

PROGRAM CODE

//GLOBAL MEMBERS int total; void count(); void ALL_IN(); void ALL_OUT(); //THE CLASS LIST STARTS HERE: class LIST {

public: char itmNo[40]; char Name[40]; int Age; unsigned long Cost; char His[100];

LIST() { clrscr();

//Creation of datafile if program opened for first time:

fstream f; f.open( "CB_LIST.DAT", ios::out | ios::noreplace ); f.close();

count(); ALL_IN(); }

~LIST() { ALL_OUT(); }

void view(); //Displays the List in tabular form void viewHis(); //Displays List with History void Search(); //Search an item on List.

void Buy(); //Deletes an item (Customer Option) void Sell(); /*Saves the details of the item to sell

for consideration (Supplier Option) */

void DEL(); //Deletes an item (Manager Option) void ADD(); //Adds an item (Manager Option) void EDIT(); //Edits an existing item (Manager Option)

private: void SORT_LIST(); //Sorts the items in the LIST acc to Item No. int Find_it(char [40]); //Finds the pos of item to delete w.r.t Item No. void Remove_it(char [40]); //Removes an item from the List

}cb[200],ob;

Page 17: THE CUBE: Antique Store

6: [4]

PROGRAM CODE

//GLOBAL MEMBERS int stotal; void scount(); void sALL_IN(); void sALL_OUT(); // THE CLASS Sup STARTS HERE: class Sup {

public:

char Name[40]; int Age; unsigned long Cost; char His[100];

Sup() { //Creation of datafile if program opened for first time:

fstream f; f.open( "CB_SALE.DAT", ios::out | ios::noreplace | ios::binary); f.close();

scount(); sALL_IN(); }

~Sup() { sALL_OUT(); }

}s[20],sob,sob2;

Page 18: THE CUBE: Antique Store

6: [5]

PROGRAM CODE

//GLOBAL MEMBERS void PASS_IN(); void PASS_OUT(); void BAL_IN(); void BAL_OUT(); // THE CLASS MNGR STARTS HERE: unsigned long bal; //balance char pass[10]; //password class Mngr {

public:

unsigned long dw; //deposit or withdraw.

Mngr() { //Creation of datafile if program opened for first time:

fstream f; f.open( "CB_PASS.DAT", ios::out | ios::noreplace ); f.close();

fstream f2; f2.open( "CB_BAL.DAT", ios::out | ios::noreplace ); f2.close();

PASS_IN(); //Retrieves the password from a datafile BAL_IN(); //Retrieves the current store balance from a datafile }

~Mngr() { PASS_OUT(); //Sends the password into a datafile BAL_OUT(); //Sends the current store balance into a datafile }

void PW(); //Function that changes the password

void Cview(); //Function that shows Store Balance

void Cdep(unsigned long); //Function that allows us to deposit money

void Cwid(unsigned long); //Function that allows us to withdraw money

void CCash(); // Function that opens the menu for CUBE CASHIER

} m1;

Page 19: THE CUBE: Antique Store

6: [6]

PROGRAM CODE

// THE FUNCTIONS THAT WORK WITH DATA FILES. // Function count Finds No of Items in Store void count() {

fstream f; f.open( "CB_LIST.DAT", ios::in | ios::binary );

int counter=0;

while( ! f.eof() ) { f.read((char*)&sob, sizeof(LIST)); counter++; };

counter--; //since one record extra is always counted.

f.close();

total=counter;

} // Reads the data from the datafile and Stores the values intohe array objects. void ALL_IN() {

fstream chew; chew.open( "CB_LIST.DAT", ios::in | ios::binary );

int i=0;

while( i<total ) {

chew.read((char*)&ob, sizeof(ob));

strcpy(cb[i].itmNo, ob.itmNo); strcpy(cb[i].Name, ob.Name); cb[i].Age=ob.Age; cb[i].Cost=ob.Cost; strcpy(cb[i].His, ob.His );

i++; };

chew.close();

}

Page 20: THE CUBE: Antique Store

6: [7]

PROGRAM CODE

// Writes the data from the array objects into the data file. void ALL_OUT() {

fstream blow; blow.open( "CB_LIST.DAT", ios::out | ios::binary | ios::trunc );

int i=0;

while( i<total ) {

blow.write((char*)&cb[i], sizeof(LIST)); i++;

};

blow.close();

} // Counts the no of Supplier offers for the manager to decide on later. void scount() {

fstream f; f.open( "CB_SALE.DAT", ios::in | ios::binary );

int counter=0;

while( ! f.eof() ) {

f.read((char*)&sob2, sizeof(sob2)); counter++;

};

counter--; //since one record extra is always counted.

f.close();

stotal=counter;

}

Page 21: THE CUBE: Antique Store

6: [8]

PROGRAM CODE

// Reads the data from the data file and Stores the values into the array objects. void sALL_IN() {

fstream chew; chew.open( "CB_SALE.DAT", ios::in | ios::binary );

int i=0;

while( i < stotal ) {

chew.read((char*)&sob, sizeof(sob));

strcpy(s[i].Name, sob.Name); s[i].Age=sob.Age; s[i].Cost=sob.Cost; strcpy(s[i].His, sob.His );

i++; };

chew.close();

} // Writes the data from the array objects into the data file. void sALL_OUT() {

fstream blow; blow.open( "CB_SALE.DAT", ios::out | ios::binary | ios::trunc );

int i=0;

while( i< stotal ) {

blow.write((char*)&s[i], sizeof(LIST)); i++;

};

blow.close();

}

Page 22: THE CUBE: Antique Store

6: [9]

PROGRAM CODE

// Retrieves the store balance from the Data File. void BAL_IN() {

fstream chew; chew.open( "CB_BAL.DAT", ios::in); chew>>bal;

chew.close();

} // Stores the Store Balance into the Data File. void BAL_OUT() {

fstream blow; blow.open( "CB_BAL.DAT", ios::out | ios::binary | ios::trunc );

blow<<bal;

blow.close();

} // Retrieves the Password from the Data File. void PASS_IN() {

fstream chew; chew.open( "CB_PASS.DAT", ios::in);

chew>>pass;

chew.close();

} // Stores the Password into the Data File. void PASS_OUT() {

fstream blow; blow.open( "CB_PASS.DAT", ios::out | ios::binary | ios::trunc );

blow<<pass;

blow.close();

}

Page 23: THE CUBE: Antique Store

6: [10]

PROGRAM CODE

// THE CLASS MNGR FUNCTIONS: void Mngr ::PW() {

char Upass[10]; //user pass cout<<"\n Please enter the new Password (10 char)\n "; gets(Upass); cout<<"\n Your Password has been Changed from”; cout<<“ \" "<<pass<<" \" to \" "<<Upass<<" \" .\n"; strcpy(pass,Upass);

} void Mngr ::Cview() {

cout<<"\n The Balance in your Account: "<<bal; cout<<endl;

} void Mngr ::Cdep(unsigned long dep=-1) {

if(dep==-1) //by manager { cout<<"\n How much money to deposit into Account?\n "; cin>>dw; cin.ignore();

bal+=dw;

Cview(); } else { bal+=dep; }

} void Mngr ::Cwid(unsigned long wid=-1) {

if(wid==-1) //by manager { cout<<"\n How much money to withdraw into Account?\n "; cin>>dw; cin.ignore();

if( dw>bal ) { cout<<"\n There is not enough money to withdraw."; } else {bal-=dw; }

Cview(); } else { bal-=wid; }

}

Page 24: THE CUBE: Antique Store

6: [11]

PROGRAM CODE

void Mngr::CCash() {

int ch; char ok; cout<<"\n Welcome to The Cube Cashier."; do { cout<<"\n Choose Among The Options Below: \n\n 1. View Balance\n\n 2.

Deposit\n\n 3. Withdraw \n "; cout<<"\n Your Choice (1-3) :"; cin>>ch; cin.ignore(); cout<<endl;

switch(ch) { case 1: Cview(); break; case 2: Cdep(); break; case 3: Cwid(); break; default: cout<<"\n Invalid Option."; }

cout<<"\n Exit Cube Cashier? (Y/N) :"; cin.get(ok); cout<<endl;

}while(ok=='n' || ok=='N');

}

Page 25: THE CUBE: Antique Store

6: [12]

PROGRAM CODE

// THE CLASS LIST FUNCTIONS: void LIST::view() {

SORT_LIST();

Space(33,"_",'_'); Space(41,"THE LIST",'_'); cout<<endl; Space(12,"Item No | "); Space(42,"Name of Item"); Space(7,"| Age"); Space(12,"| Cost");

cout<<"|\n\n";

for(int j=0; j<total; j++) {

Space(12,cb[j].itmNo); Space(42,cb[j].Name); Space(7,cb[j].Age); Space(12,cb[j].Cost);

cout<<"\n\n";

if((j+1)%10==0 && j!=0 && total>10) { cout<<" See the next 10 items? (Y/N) : "; char ch; cin.get(ch); cout<<endl;

if(ch=='y' || ch=='Y') continue; else break; } } //End of for loop.

//Exception Handling if(total==0) { Space(22,""); Space(52,"<<<< NO ITEMS FOUND! >>>>"); cout<<endl<<endl; }

Space(27,"_",'_'); Space(47,"[Enter To Continue]",'_'); cout<<endl; getch(); cout<<endl;

}

Page 26: THE CUBE: Antique Store

6: [13]

PROGRAM CODE

void LIST::viewHis() {

char temp[100]; SORT_LIST();

Space(31,"_",'_'); Space(43,"THE HISTORY",'_'); cout<<endl; Space(12,"Item No | "); Space(42,"Name of Item"); Space(7,"| Age"); Space(12,"| Cost");

cout<<"|\n\n";

for(int i=0; i<total; i++) {

Space(12,cb[i].itmNo); Space(42,cb[i].Name); Space(7,cb[i].Age); Space(12,cb[i].Cost); cout<<"\n\n"; Space(12," | HISTORY: "); Space(57, cb[i].His ); cout<<endl; if( (i+1)!=total ) Space(74,"",'_'); cout<<"\n\n";

if( (i+1)%5==0 && i!=0 && total>5) { cout<<" See the next 5 items? (Y/N) : "; char ch; cin.get(ch); cout<<endl;

if(ch=='y' || ch=='Y') { clrscr();

Space(31,"_",'_'); Space(43,"THE HISTORY",'_'); cout<<endl; Space(12,"Item No | "); Space(42,"Name of Item"); Space(7,"| Age"); Space(12,"| Cost");

cout<<"|\n\n";

continue; } else break; } //end of outer if loop } //end of for loop

Page 27: THE CUBE: Antique Store

6: [14]

PROGRAM CODE

//Exception Handling

if(total==0) { Space(22,""); Space(52,"<<<< NO ITEMS FOUND! >>>>"); cout<<endl<<endl; } Space(27,"_",'_'); Space(47,"[Enter To Continue]",'_'); cout<<endl; getch(); cout<<endl;

} void LIST::SORT_LIST() {

char tempIN[40]; char tempName[40]; int tempAge; unsigned long tempCost; char tempHis[100];

int i; int flag=0;

for(i=total; i>0; i--) {

for(int j=0; j<i-1; j++) { //To Compare the Strings.

for(int o=0; o<strlen(cb[j].itmNo); o++) { if(cb[j].itmNo[o]==cb[j+1].itmNo[o]) continue;

else if(cb[j].itmNo[o]>cb[j+1].itmNo[o]) { flag=1; break; }

else {flag=0; break;}

} //inner most for loop.

if(flag==1) { strcpy(tempIN,cb[j].itmNo); strcpy(c b[j].itmNo,cb[j+1].itmNo); strcpy(cb[j+1].itmNo,tempIN);

strcpy(tempName,cb[j].Name); strcpy(cb[j].Name,cb[j+1].Name); strcpy(cb[j+1].Name,tempName);

Page 28: THE CUBE: Antique Store

6: [15]

PROGRAM CODE

tempAge=cb[j].Age; cb[j].Age=cb[j+1].Age; cb[j+1].Age=tempAge;

tempCost=cb[j].Cost; cb[j].Cost=cb[j+1].Cost; cb[j+1].Cost=tempCost;

strcpy(tempHis,cb[j].His); strcpy(cb[j].His,cb[j+1].His); strcpy(cb[j+1].His,tempHis);

} //END OF COMPARING STRING (IF STATEMENT) } //END OF INNER FOR LOOP } //END OF OUTER FOR LOOP

} void LIST::Search() {

int i; char S[40]; char Su[40]; char Sl[40];

Space(33,"_",'_'); Space(41,"THE SEARCH",'_'); cout<<endl;

cout<<"\n Which entity to search in?"; cout<<"\n\n 1. Name\n\n 2. Age\n\n 3. Cost\n\n 4. History\n\n Your Choice

(1-4) : "; int ch; cin>>ch;

switch(ch) {

case 1:

cout<<"\n Enter a Word to Search for: "; gets(S);

//to remove the case sensitivity of a search. for(i=0; i<strlen(S); i++) { Su[i]=toupper(S[i]); Sl[i]=tolower(S[i]); }

cout<<"\n"; Space(30,"_",'_'); Space(44,"SEARCH RESULTS",'_'); cout<<endl; Space(12,"Item No | "); Space(42,"Name of Item"); Space(7,"| Age"); Space(12,"| Cost"); cout<<"|";

Page 29: THE CUBE: Antique Store

6: [16]

PROGRAM CODE

cout<<"\n\n"; int count=0; //counts no of letters in each word int J=0; //a memory location for temporary positions. int flag=0;

// Outer loop searches moves from item to item nof LIST for(i=0; i<total; i++) {

//Making Last character of every String/Name an End of Word character // i.e <space> if( cb[i].Name[ (strlen(cb[i].Name)-1) ] !=' ' ) cb[i].Name[ (strlen(cb[i].Name)) ]=' ';

// Inner loop compares word by word of an item NAME at a time

for(int j=0; j< strlen( cb[i].Name ) ; j++) { J=j-1;

if(cb[i].Name[j]==' ') continue;

do //Finds total length of the word. {

J++; count++; } while(cb[i].Name[J+1] != ' ');

//outermost if if(count==strlen(S)) { //if the lengths of searched item and word are same.

if( (cb[i].Name[j]==Su[0]) || (cb[i].Name[j]==Sl[0]) ) { // if the first character of both searched item and name is same

// Innermost loop compares character by character from // the starting of each word in the Item Name. for(int o=0; o<count; o++) { if(cb[i].Name[j+o]==Su[o] || cb[i].Name[j+o]==Sl[o]) { // if the character of the searched word and word in the Item Name is same if(o==count-1) // if this is the last character { flag=1; Space(12,cb[i].itmNo); Space(42,cb[i].Name); Space(7,cb[i].Age); Space(12,cb[i].Cost); cout<<"\n\n"; }//end of innermost if

Page 30: THE CUBE: Antique Store

6: [17]

PROGRAM CODE

} // end of if statement that checks first character of both words else {break; } //end of 3rd inner if-else }//end of innermost for loop }//end of inner if loop

}//outermost if

//moves the counter ( j )of the loop that searches word by word to the next //word of item Name.

j+=(count-1); count=0;

} //inner for loop. } //outer loop. //Exception Handling if(flag==0) { Space(22,""); Space(52,"<<<< NO SUCH ITEM FOUND! >>>>"); cout<<endl<<endl; } Space(27,"_",'_'); Space(47,"[Enter To Continue]",'_'); getch(); break;

Page 31: THE CUBE: Antique Store

6: [18]

PROGRAM CODE

case 4: //The Search in the History of an item is the same //as the Search in the Name of the item

cout<<"\n Enter a Word to Search for: "; gets(S);

//to remove the case sensitivity of a search. for(i=0; i<strlen(S); i++) { Su[i]=toupper(S[i]); Sl[i]=tolower(S[i]); }

cout<<"\n"; Space(30,"_",'_'); Space(44,"SEARCH RESULTS",'_'); cout<<endl; Space(12,"Item No | "); Space(42,"Name of Item"); Space(7,"| Age"); Space(12,"| Cost"); cout<<"|";

cout<<"\n\n";

count=0; //counts no of letters in each word J=0; //a memory location for temporary positions. flag=0;

for(i=0; i<total; i++) {

if( cb[i].His[ (strlen(cb[i].His)-1) ] !=' ' ) cb[i].His[ (strlen(cb[i].His)) ]=' ';

for(int j=0; j< strlen( cb[i].His ) ; j++) { J=j-1;

if(cb[i].His[j]==' ') continue;

//Finds total length of the word. do {

J++; count++;

} while(cb[i].His[J+1] != ' ');

//outermost if if(count==strlen(S)) { //if the lengths of searched item and word is same.

if( (cb[i].His[j]==Su[0]) || (cb[i].His[j]==Sl[0]) )

Page 32: THE CUBE: Antique Store

6: [19]

PROGRAM CODE

{ for(int o=0; o<count; o++) { if(cb[i].His[j+o]==Su[o] || cb[i].His[j+o]==Sl[o]) { if(o==count-1) { flag=1; Space(12,cb[i].itmNo); Space(42,cb[i].Name); Space(7,cb[i].Age); Space(12,cb[i].Cost); cout<<"\n"; Space(12," | "); Space(10, "History: "); cout<<"\n"; Space(12," | "); Space(70, cb[i].His); cout<<"... "; cout<<"\n\n\n"; } //end of 4th inner if } else { break; } }//end of innermost for loop }//end of if loop } //outermost if

j+=(count-1); count=0;

} //inner for loop.

} //outer loop.

if(flag==0) { Space(22,""); Space(52,"<<<< NO SUCH ITEM FOUND! >>>>"); cout<<endl<<endl; } Space(27,"_",'_'); Space(47,"[Enter To Continue]",'_'); getch();

break;

Page 33: THE CUBE: Antique Store

6: [20]

PROGRAM CODE

case 2: //Search in Age of Item

unsigned long U,L; //upper limit, lower limit flag=0;

cout<<"\n Enter the Upper Limit and Lower Limit. (Both Included in Search.)\n";

cout<<"\n \t\t\t Lower Limit: "; cin>>L; cout<<" \t\t\t Upper Limit: "; cin>>U;

cout<<"\n\n \t\t\t [ "<<L<<" <--> "<<U<<" ]"; cout<<endl;

cout<<"\n"; Space(30,"_",'_'); Space(44,"SEARCH RESULTS",'_'); cout<<endl; Space(12,"Item No | "); Space(42,"Name of Item"); Space(7,"| Age"); Space(12,"| Cost"); cout<<"|";

cout<<"\n\n";

for(i=0; i<total; i++) {

if( cb[i].Age >=L && cb[i].Age <=U ) {

flag=1; Space(12,cb[i].itmNo); Space(42,cb[i].Name); Space(7,cb[i].Age); Space(12,cb[i].Cost); cout<<"\n\n";

}

} //EXCEPTION HANDLING:

if(flag==0) { Space(22,""); Space(52,"<<<< NO SUCH ITEM FOUND! >>>>"); cout<<endl<<endl; } Space(27,"_",'_'); Space(47,"[Enter To Continue]",'_'); getch();

break;

Page 34: THE CUBE: Antique Store

6: [21]

PROGRAM CODE

case 3: //Search in Cost // It is the same as the search in age, //except for the fact that Cost is an unsigned long datatype, //and Age is an integer datatype

flag=0;

cout<<"\n Enter the Upper Limit and Lower Limit. (Both Included in Search.)\n";

cout<<"\n \t\t\t Lower Limit: "; cin>>L; cout<<" \t\t\t Upper Limit: "; cin>>U;

cout<<"\n\n \t\t\t [ "<<L<<" <--> "<<U<<" ]"; cout<<endl;

cout<<"\n"; Space(30,"_",'_'); Space(44,"SEARCH RESULTS",'_'); cout<<endl; Space(12,"Item No | "); Space(42,"Name of Item"); Space(7,"| Age"); Space(12,"| Cost"); cout<<"|";

cout<<"\n\n";

for(i=0; i<total; i++) {

if( cb[i].Cost >=L && cb[i].Cost <=U ) {

flag=1; Space(12,cb[i].itmNo); Space(42,cb[i].Name); Space(7,cb[i].Age); Space(12,cb[i].Cost); cout<<"\n\n";

} } if(flag==0)

{ Space(22,""); Space(52,"<<<< NO SUCH ITEM FOUND! >>>>"); cout<<endl<<endl; } Space(27,"_",'_'); Space(47,"[Enter To Continue]",'_'); getch();

break;

default: cout<<"Invalid Choice. "<<'\n'; } //end of switch case

} // End of Search()

Page 35: THE CUBE: Antique Store

6: [22]

PROGRAM CODE

int LIST::Find_it(char chk[40]) {

int pos=-5;

//String Comparism for(int i=0; i<total; i++) {

if(chk[0]==cb[i].itmNo[0]) { for(int j=0; j<strlen(cb[i].itmNo); j++) { if(chk[j]==cb[i].itmNo[j]) { if(j==strlen(cb[i].itmNo)-1) pos=i; } else { break; } } } }

return pos;

} void LIST::Remove_it(char chk[40]) {

int pos=Find_it(chk); //Deleting the items at position pos:

for(int i=pos; i<total-1; i++) { strcpy(cb[i].itmNo,cb[i+1].itmNo); strcpy(cb[i].Name, cb[i+1].Name); cb[i].Age=cb[i+1].Age; cb[i].Cost=cb[i+1].Cost; } total--;

}

Page 36: THE CUBE: Antique Store

6: [23]

PROGRAM CODE

void LIST::DEL() {

char chk[40]; char ok='n';

do { cout<<" Enter the item number of the item you wish to delete.\n "; gets(chk);

int pos=Find_it(chk);

if(pos==-5) //Error Handling { cout<<" No such Item Number. \n You may have typed it Wrong."<<'\n'; cout<<"\n\n Try again (y/n) ?\n "; cin.get(ok); cin.ignore(); //Buffer error removed.

cout<<"\n"; } else { Remove_it(chk); cout<<"\n\n The Item has been deleted.\n\n"; ok='n'; }

} while(ok=='y' || ok=='Y');

char ok2='n'; cout<<" Would you like to see THE LIST? (Y/N) \n "; cin.get(ok2);

if(ok2=='y' || ok2=='Y') { cout<<"\n\n"; view(); }

}

Page 37: THE CUBE: Antique Store

6: [24]

PROGRAM CODE

void LIST::Buy() {

char ok='n'; int pos[5]; int count=-1; char chk[5][40];

char bought='n';

do {count+ +;

cout<<" Enter the item number of the item you wish to buy\n "; gets(chk[count]);

//Error Handling : You can not buy same item twice. int ok3=0;

for(int i=0; i<count; i++) { if(strcmp(chk[count],chk[i])==0) ok3=1; }

if(ok3==1) {cout<<"\n You cannot buy the same item twice! \n\n"; count--; continue; } //END OF ERROR HANDLING.

pos[count]=Find_it(chk[count]);

//Error Handling: Wrong Item Number Entered. if(pos[count]==-5) { cout<<"\n INVALID Item Number. Try Again. (y/n) \n "; count--; ok='n'; } //To allow users to buy more than one item. max 5. else { bought='y'; cout<<"\n Buy Another item? (y/n) [MAX: 5 items per Bill] \n "; }

cin.get(ok); cout<<endl; cin.ignore(); //Buffer error } while(ok=='y' || ok=='Y');

if(bought=='y') {

Space(20,"_",'_'); Space(30,"BILL",'_'); cout<<endl; Space(40,"| Name");

Page 38: THE CUBE: Antique Store

6: [25]

PROGRAM CODE

Space(1 0,"| Cost"); cout<<endl;

unsigned long totalcost=0;

for(int i=0; i<=count; i++) { Space(40,cb[pos[i]].Name); Space(10,cb[pos[i]].Cost); totalcost+=cb[pos[i]].Cost; cout<<endl; }

Space(20,"_",'_'); Space(30,"_",'_'); cout<<endl; Space(40," TOTAL: "); Space(10,totalcost);

cout<<"\n\n Thank you for shopping at This Antique Store. \n";

for(i=0; i<=count; i++) { Remove_it(cb[pos[i]].itmNo); }

bal+=totalcost; //increasing store balance. } else { cout<<"\n Hope you find something of interest next time."; }

}

Page 39: THE CUBE: Antique Store

6: [26]

PROGRAM CODE

void LIST::EDIT() {

char chk[40]; cout<<" Enter the Item No of the Item to Edit\n "; gets(chk);

int pos=Find_it(chk); if(pos==-5) cout<<"\n Invalid Item No.";

else { char ok='n';

do { cout<<"\n Which entity do you want to edit?"; cout<<"\n\n 1. Name\n\n 2. Age\n\n 3. Cost\n\n 4. History\n\n Your

Choice (1-4) : "; int ch; cin>>ch; cin.ignore();

switch(ch) { case 1: cout<<"\n Enter the new Name: "; char name[40]; gets(name); strcpy(cb[pos].Name,name); break;

case 2: cout<<"\n Enter the new Age: "; int age; cin>>age; cb[pos].Age=age; break;

case 3: cout<<"\n Enter the new Cost: "; unsigned long cost; cin>>cost; cb[pos].Cost=cost; break;

case 4: cout<<"\n Enter the new History:\n "; char his[100]; gets(his); strcpy(c b[pos].His , his); break;

default: cout<<" INVALID CHOICE. \n"; } cin.ignore(); cout<<" \n\n Any more EDITs on this item? (Y/N) : "; cin.get(ok);

} while(ok=='y' || ok=='Y');

cout<<" \n Your EDITING has been successful! ";

}

Page 40: THE CUBE: Antique Store

6: [27]

PROGRAM CODE

} // END OF EDIT() void LIST::ADD() { cout<<"\n TO ADD AN ITEM TO THE STORE.\n\n 1. From Supplier\n\n 2. From Manager.\n\n ";

cout<<"Your Choice (1-2) : "; int chk; cin>>chk;

int i;

switch(chk) { case 1:

if( stotal > 0 ) {

for(i=0; i<stotal; i++) { cout<<"\n Item #"<<(i+1); cout<<"\n Name of Item : "<<s[i].Name; cout<<"\n Age of Item : "<<s[i].Age; cout<<"\n Asked Price : "<<s[i].Cost; cout<<"\n History : "<<s[i].His;

cout<<"\n\n ACCEPT OR DECLINE? (A/D): ";

char ch2; cin>>ch2; cout<<endl;

if(ch2=='a' || ch2=='A') { for(int j=0; j<1; j++) { cout<<" Enter the Item No of new Item:\n "; gets(cb[total].itmNo);

//ERROR HANDLING. ITEM NO MUST BE UNIQUE.

if(Find_it(cb[total].itmNo)!=-5) //if item number as such exists

{ cout<<" Entered Item Number Already Exists. RETRY! \n\n";

j--; continue; } //END OF ERROR HANDLING. } //END of inner FOR LOOP

cout<<"\n Enter the new Item's Price:\n "; cin>>cb[total].Cost;

m1.Cwid(s[i].Cost);

//removing asked price by supplier from the store balance. strcpy( cb[total].Name,s[i].Name );

Page 41: THE CUBE: Antique Store

6: [28]

PROGRAM CODE

cb[total].Age=s[i].Age; strcpy( cb[total].His,s[i].His ); total++; } else if(ch2=='d' || ch2=='D') { cout<<" Item is Declined.\n"; } if( (i+1) == stotal ) { cout<<"\n No More Items By Supplier.\n"; //clearing the CB_SALE.dat

fstream f; f.open("CB_SALE.DAT", ios::out | ios::trunc ); f.close(); //end of clearing } } //end of for loop.

//Deleting items from the Supplier Waiting List.

stotal=0;

} else { cout<<"\n No Items by Supplier \n"; } break;

case 2:

cout<<"\n How many items to add? : "; int noi; cin>>noi; //no of items to sell cout<<endl;

for(i=0; i<noi; i++) { cout<<"\n Item To Add ("<<(i+1)<<"/"<<noi<<")\n\n";

cout<<" Enter the Item No of new Item : "; gets(cb[total].itmNo);

//ERROR HANDLING. ITEM NO MUST BE UNIQUE. if(Find_it(cb[total].itmNo)!=-5) //if itm number as such exists {cout<<"\n Entered Item Number Already Exists. RETRY! \n\n"; i--; continue; } //END OF ERROR HANDLING.

cout<<"\n Enter the Name of the Item : "; gets(cb[total].Name); cout<<"\n Enter the Age of the Item : "; cin>>cb[total].Age; cout<<"\n Enter the Item's Price : "; cin>>cb[total].Cost; cout<<"\n Enter the Item's History : "; gets(cb[total].His);

total++; }

Page 42: THE CUBE: Antique Store

6: [29]

PROGRAM CODE

break;

default: cout<<"\n Invalid Choice."; } //End of Switch Case

char ok='n'; cin.ignore(); cout<<"\n Would you like to see THE LIST? (Y/N) : "; cin.get(ok); cin.ignore(); if(ok=='y' || ok=='Y') { cout<<"\n\n"; view(); }

} void LIST::Sell() {

cout<<"\n Welcome Supplier.\n How many items to sell?\n "; int noi; cin>>noi; //no of items to sell cout<<endl;

for(int i=0; i<noi; i++) { cout<<"\n Item To Sell No:"<<(i+1)<<"\n\n"; cout<<" Enter the Name of the Item: "; gets(s[stotal].Name); cout<<"\n Enter the Age of the Item: "; cin>>s[stotal].Age; cout<<"\n Enter your Selling Price: "; cin>>s[stotal].Cost; cout<<"\n Enter Item's History: "; gets(s[stotal].His); stotal++; }

cout<<"\n Thank you for your offer. \n";

}

Page 43: THE CUBE: Antique Store

6: [30]

PROGRAM CODE

// THE VOID MAIN FUNCTION: void main() { int ch;

do {

clrscr();

Space(74,"",'_'); cout<<endl; Space(33,"",'_'); Space(41,"MAIN MENU",'_'); cout<<endl;

Space(25,"\n 1. THE LIST"); Space(28," | Shows the List of items on Sale."); cout<<endl;

Space(25,"\n 2. THE HISTORY"); Space(28," | Learn more about an Item or Store"); cout<<endl;

Space(25,"\n 3. THE SEARCH "); Space(28," | Can't Find what you're looking for?",' '); cout<<endl;

Space(25,"\n 4. I AM A CUSTOMER"); Space(28," | Buy something nice for Yourself."); cout<<endl;

Space(25,"\n 5. I AM A SUPPLIER"); Space(28," | Sell us something We may like."); cout<<endl;

Space(25,"\n 6. I AM THE MANAGER"); Space(28," | A Password Protected Control Centre. "); cout<<endl;

Space(25,"\n 0. EXIT."); Space(28," | Done here? Leave the Online Store."); cout<<endl;

Space(74,"",'_'); cout<<"\n\n Your Choice (0-6): ";

cin>>ch; cin.ignore(); cout<<endl;

clrscr();

switch(ch) { case 1: ob.view(); break;

case 2: ob.viewHis(); break;

case 3: ob.Search(); break;

Page 44: THE CUBE: Antique Store

6: [31]

PROGRAM CODE

case 4: cout<<endl; Space(30,"_",'_'); Space(44,"I AM A CUSTOMER",'_'); cout<<endl; cout<<endl;

ob.Buy();

cout<<endl; Space(27,"_",'_'); Space(47,"[Enter To Continue]",'_'); getch(); break;

case 5: cout<<endl; Space(30,"_",'_'); Space(44,"I AM A SUPPLIER",'_'); cout<<endl; cout<<endl;

ob.Sell();

cout<<endl; Space(27,"_",'_'); Space(47,"[Enter To Continue]",'_'); getch(); break;

case 6: int ch2;

cout<<" Enter the Password: \n "; char ps[10]; gets(ps);

if(strcmp(ps,pass)==0) { cout<<"\n Welcome Back Manager.\n\n";

do {

clrscr();

cout<<endl; Space(29,"_",'_'); Space(45,"I AM THE MANAGER",'_'); cout<<endl; cout<<endl;

Space(33,"\n 1. CHANGE THE PASSWORD "); Space(20," | Be Safe & Secure. "); cout<<endl;

Space(33,"\n 2. ADD AN ITEM TO THE LIST "); Space(20," | More items to add? "); cout<<endl;

Space(33,"\n 3. EDIT AN ITEM ON THE LIST "); Space(20," | Make some Changes. ",' '); cout<<endl;

Space(33,"\n 4. DELETE AN ITEM FROM THE LIST");

Page 45: THE CUBE: Antique Store

6: [32]

PROGRAM CODE

Space(20," | Remove the Unwanted."); cout<<endl;

Space(33,"\n 5. USE THE CUBE CASHIER "); Space(20," | Check. Deposit. Withdraw."); cout<<endl;

Space(33,"\n 0. EXIT."); Space(20," | Done? Log out Safely."); cout<<endl;

Space(74,"",'_'); cout<<"\n\n Your Choice (0-5): ";

cin>>ch2; cin.ignore(); cout<<endl;

clrscr(); cout<<endl; Space(29,"_",'_'); Space(45,"I AM THE MANAGER",'_'); cout<<endl; cout<<endl;

switch(ch2) { case 1: m1.PW(); break;

case 2: ob.ADD(); break;

case 3:

ob.EDIT();

cout<<endl; Space(27,"_",'_'); Space(47,"[Enter To Continue]",'_'); getch(); break;

case 4: ob.DEL(); break;

case 5: m1.CCash(); break;

case 0:

cout<<"\n Thank you & Goodbye Manager! You Have been logged out Safely. \n";

cout<<endl; Space(2 7,"_",'_'); Space(47,"[Enter To Continue]",'_'); getch(); break;

default: cout<<"\n INVALID CHOICE! RETRY! \n";

} }

while(ch2!=0);

Page 46: THE CUBE: Antique Store

6: [33]

PROGRAM CODE

} else { cout<<"\n Wrong Password!\n "; getch(); }

break;

default: cout<<"\n\n Thank you For Visitng & Come Again Soon! "; }

}while(ch!=0); getch(); }

Page 47: THE CUBE: Antique Store

7: [1]

SAMPLE INPUT & OUTPUT

__________________________________________________________________________ _________________________________MAIN MENU________________________________ 1. THE LIST | Shows the List of items on Sale. 2. THE HISTORY | Learn more about an Item or Store 3. THE SEARCH | Can't Find what you're looking for? 4. I AM A CUSTOMER | Buy something nice for Yourself. 5. I AM A SUPPLIER | Sell us something We may like.

6. I AM THE MANAGER | A Password Protected Control Centre. 0. EXIT. | Done here? Leave the Online Store. __________________________________________________________________________ Your Choice (0-6): 1 _________________________________THE LIST_________________________________ Item No | Name of Item | Age| Cost| #23022 Compass of Peter Tsar The Terrible 140 7000000 #23023 Gustave's Blueprints 120 6000000 #23032 Hitler's Globe 76 3800000 #23033 Karl's Ink Pen 125 6250000 #23058 Katana of Shogan Tokugawa 414 20700000 #23059 Mahatma Gandhi's Spectacles 62 3100000 #23067 Red Barron's Remains 96 4800000 #23076 Silver Claws Of Maharana 74 3700000 #23077 Stallon's Lost Diary 76 3800000 #23081 Sword of Tipu Sultan 87 4350000 See the next 10 items? (Y/N) : Y #23091 The Pharaoh's Sceptre 124 6200000 #23096 Viking's Sledgehammer 168 8400000 ___________________________[Enter To Continue]____________________________

Page 48: THE CUBE: Antique Store

7: [2]

SAMPLE INPUT & OUTPUT

__________________________________________________________________________ _________________________________MAIN MENU________________________________ 1. THE LIST | Shows the List of items on Sale. 2. THE HISTORY | Learn more about an Item or Store 3. THE SEARCH | Can't Find what you're looking for? 4. I AM A CUSTOMER | Buy something nice for Yourself. 5. I AM A SUPPLIER | Sell us something We may like. 6. I AM THE MANAGER | A Password Protected Control Centre. 0. EXIT. | Done here? Leave the Online Store. __________________________________________________________________________ Your Choice (0-6): 2 _______________________________THE HISTORY________________________________ Item No | Name of Item | Age| Cost| #23022 Compass of Peter Tsar The Terrible 140 7000000 | HISTORY: The compass used by the famous conqueror __________________________________________________________________________ #23023 Gustave's Blueprints 120 6000000 | HISTORY: The original blueprints of the Eiffel Tower __________________________________________________________________________ #23032 Hitler's Globe 76 3800000 | HISTORY: The globe he used to strategize his conquests __________________________________________________________________________ #23033 Karl's Ink Pen 125 6250000 | HISTORY: He wrote the Communist Manifesto with this pen __________________________________________________________________________ #23058 Katana of Shogan Tokugawa 414 20700000 | HISTORY: The sword of the first Shogun of the Tokugawa clan __________________________________________________________________________ See the next 5 items? (Y/N) : Y _______________________________THE HISTORY________________________________ Item No | Name of Item | Age| Cost| #23059 Mahatma Gandhi's Spectacles 62 3100000 | HISTORY: See the world through the eyes of this reputed freedom fighter __________________________________________________________________________ #23067 Red Barron's Remains 96 4800000 | HISTORY: The famous fighter plane from World War 1 __________________________________________________________________________ #23076 Silver Claws Of Maharana 74 3700000 | HISTORY: The weapon he was most skilled in __________________________________________________________________________ #23077 Stallon's Lost Diary 76 3800000 | HISTORY: The journal where he wrote his strategies and plans __________________________________________________________________________ #23081 Sword of Tipu Sultan 87 4350000 | HISTORY: The sword he held before he met his death

Page 49: THE CUBE: Antique Store

7: [3]

SAMPLE INPUT & OUTPUT

__________________________________________________________________________ See the next 5 items? (Y/N) : Y _______________________________THE HISTORY________________________________ Item No | Name of Item | Age| Cost| #23091 The Pharaoh's Sceptre 124 6200000 | HISTORY: An Egyptian artefact that was a symbol of authority __________________________________________________________________________ #23096 Viking's Sledgehammer 168 8400000 | HISTORY: A weapon of great power used by the Vikings ___________________________[Enter To Continue]____________________________

Page 50: THE CUBE: Antique Store

7: [4]

SAMPLE INPUT & OUTPUT

__________________________________________________________________________ _________________________________MAIN MENU________________________________ 1. THE LIST | Shows the List of items on Sale. 2. THE HISTORY | Learn more about an Item or Store 3. THE SEARCH | Can't Find what you're looking for? 4. I AM A CUSTOMER | Buy something nice for Yourself. 5. I AM A SUPPLIER | Sell us something We may like. 6. I AM THE MANAGER | A Password Protected Control Centre. 0. EXIT. | Done here? Leave the Online Store. __________________________________________________________________________ Your Choice (0-6): 3 _________________________________THE SEARCH_______________________________ Which entity to search in? 1. Name 2. Age 3. Cost 4. History Your Choice (1-4) : 1 Enter a Word to Search for: gLoBe ______________________________SEARCH RESULTS______________________________ Item No | Name of Item | Age| Cost| #23032 Hitler's Globe 76 3800000 ___________________________[Enter To Continue]____________________________ _________________________________THE SEARCH_______________________________ Which entity to search in? 1. Name 2. Age 3. Cost 4. History Your Choice (1-4) : 3 Enter the Upper Limit and Lower Limit. (Both Included in Search.) Lower Limit: 0 Upper Limit: 1000000 [ 0 <--> 1000000 ] ______________________________SEARCH RESULTS______________________________ Item No | Name of Item | Age| Cost| <<<< NO SUCH ITEM FOUND! >>>> ___________________________[Enter To Continue]____________________________

Page 51: THE CUBE: Antique Store

7: [5]

SAMPLE INPUT & OUTPUT

_________________________________THE SEARCH_______________________________ Which entity to search in? 1. Name 2. Age 3. Cost 4. History Your Choice (1-4) : 2 Enter the Upper Limit and Lower Limit. (Both Included in Search.) Lower Limit: 100 Upper Limit: 200 [ 100 <--> 200 ] ______________________________SEARCH RESULTS______________________________ Item No | Name of Item | Age| Cost| #23022 Compass of Peter Tsar The Terrible 140 7000000 #23023 Gustave's Blueprints 120 6000000 #23033 Karl's Ink Pen 125 6250000 #23091 The Pharaoh's Sceptre 124 6200000 #23096 Viking's Sledgehammer 168 8400000 ___________________________[Enter To Continue]____________________________ _________________________________THE SEARCH_______________________________ Which entity to search in? 1. Name 2. Age 3. Cost 4. History Your Choice (1-4) : 4 Enter a Word to Search for: fighter ______________________________SEARCH RESULTS______________________________ Item No | Name of Item | Age| Cost| #23059 Mahatma Gandhi's Spectacles 62 3100000 | History: | See the world through the eyes of this reputed freedom fighter ... #23067 Red Barron's Remains 96 4800000 | History: | The famous fighter plane from World War 1 ... ___________________________[Enter To Continue]____________________________

Page 52: THE CUBE: Antique Store

7: [6]

SAMPLE INPUT & OUTPUT

__________________________________________________________________________ _________________________________MAIN MENU________________________________ 1. THE LIST | Shows the List of items on Sale. 2. THE HISTORY | Learn more about an Item or Store 3. THE SEARCH | Can't Find what you're looking for? 4. I AM A CUSTOMER | Buy something nice for Yourself. 5. I AM A SUPPLIER | Sell us something We may like. 6. I AM THE MANAGER | A Password Protected Control Centre. 0. EXIT. | Done here? Leave the Online Store. __________________________________________________________________________ Your Choice (0-6): 4 ______________________________I AM A CUSTOMER_____________________________ Enter the item number of the item you wish to buy #23033 Buy Another item? (y/n) [MAX: 5 items per Bill] Y Enter the item number of the item you wish to buy #23081 Buy Another item? (y/n) [MAX: 5 items per Bill] N ____________________BILL__________________________ | Name | Cost Karl's Ink Pen 6250000 Sword of Tipu Sultan 4350000 __________________________________________________ TOTAL: 10600000 Thank you for shopping at This Antique Store. ___________________________[Enter To Continue]____________________________

Page 53: THE CUBE: Antique Store

7: [7]

SAMPLE INPUT & OUTPUT

__________________________________________________________________________ _________________________________MAIN MENU________________________________ 1. THE LIST | Shows the List of items on Sale. 2. THE HISTORY | Learn more about an Item or Store 3. THE SEARCH | Can't Find what you're looking for? 4. I AM A CUSTOMER | Buy something nice for Yourself. 5. I AM A SUPPLIER | Sell us something We may like. 6. I AM THE MANAGER | A Password Protected Control Centre. 0. EXIT. | Done here? Leave the Online Store. __________________________________________________________________________ Your Choice (0-6): 1 _________________________________THE LIST_________________________________ Item No | Name of Item | Age| Cost| #23022 Compass of Peter Tsar The Terrible 140 7000000 #23023 Gustave's Blueprints 120 6000000 #23032 Hitler's Globe 76 3800000 #23058 Katana of Shogan Tokugawa 414 20700000 #23059 Mahatma Gandhi's Spectacles 62 3100000 #23067 Red Barron's Remains 96 4800000 #23076 Silver Claws Of Maharana 74 3700000 #23077 Stallon's Lost Diary 76 3800000 #23091 The Pharaoh's Sceptre 124 6200000 #23096 Viking's Sledgehammer 168 8400000 ___________________________[Enter To Continue]____________________________

Page 54: THE CUBE: Antique Store

7: [8]

SAMPLE INPUT & OUTPUT

_________________________________MAIN MENU________________________________ 1. THE LIST | Shows the List of items on Sale. 2. THE HISTORY | Learn more about an Item or Store 3. THE SEARCH | Can't Find what you're looking for? 4. I AM A CUSTOMER | Buy something nice for Yourself. 5. I AM A SUPPLIER | Sell us something We may like. 6. I AM THE MANAGER | A Password Protected Control Centre. 0. EXIT. | Done here? Leave the Online Store. __________________________________________________________________________ Your Choice (0-6): 5 ______________________________I AM A SUPPLIER_____________________________ Welcome Supplier. How many items to sell? 2 Item To Sell No:1 Enter the Name of the Item: The Orb of Galactus Enter the Age of the Item: 68 Enter your Selling Price: 5000000 Enter Item's History: The power of the cosmos trapped in an orb Item To Sell No:2 Enter the Name of the Item: The Toothpick of Gibralter Enter the Age of the Item: 45 Enter your Selling Price: 5600000 Enter Item's History: It still holds the piece of lettuce he pulled out Thank you for your offer. ___________________________[Enter To Continue]____________________________

Page 55: THE CUBE: Antique Store

7: [9]

SAMPLE INPUT & OUTPUT

__________________________________________________________________________ _________________________________MAIN MENU________________________________ 1. THE LIST | Shows the List of items on Sale. 2. THE HISTORY | Learn more about an Item or Store 3. THE SEARCH | Can't Find what you're looking for? 4. I AM A CUSTOMER | Buy something nice for Yourself. 5. I AM A SUPPLIER | Sell us something We may like. 6. I AM THE MANAGER | A Password Protected Control Centre. 0. EXIT. | Done here? Leave the Online Store. __________________________________________________________________________ Your Choice (0-6): 6 Enter the Password: Hamburger _____________________________I AM THE MANAGER_____________________________ 1. CHANGE THE PASSWORD | Be Safe & Secure. 2. ADD AN ITEM TO THE LIST | More items to add? 3. EDIT AN ITEM ON THE LIST | Make some Changes. 4. DELETE AN ITEM FROM THE LIST | Remove the Unwanted. 5. USE THE CUBE CASHIER | Check. Deposit. Withdraw. 0. EXIT. | Done? Log out Safely. __________________________________________________________________________ Your Choice (0-5): 1 _____________________________I AM THE MANAGER_____________________________ Please enter the new Password (10 char) pass Your Password has been Changed from " Hamburger " to " pass " . ___________________________[Enter To Continue]____________________________

Page 56: THE CUBE: Antique Store

7: [10]

SAMPLE INPUT & OUTPUT

_____________________________I AM THE MANAGER_____________________________ 1. CHANGE THE PASSWORD | Be Safe & Secure. 2. ADD AN ITEM TO THE LIST | More items to add? 3. EDIT AN ITEM ON THE LIST | Make some Changes. 4. DELETE AN ITEM FROM THE LIST | Remove the Unwanted. 5. USE THE CUBE CASHIER | Check. Deposit. Withdraw. 0. EXIT. | Done? Log out Safely. __________________________________________________________________________ Your Choice (0-5): 2 _____________________________I AM THE MANAGER_____________________________ TO ADD AN ITEM TO THE STORE. 1. From Supplier 2. From Manager. Your Choice (1-2) : 1 Item #1 Name of Item : The Orb of Galactus Age of Item : 68 Asked Price : 5000000 History : The power of the cosmos trapped in an orb ACCEPT OR DECLINE? (A/D): D Item is Declined. Item #2 Name of Item : The Toothpick of Gibralter Age of Item : 45 Asked Price : 5600000 History : It still holds the piece of lettuce he pulled out ACCEPT OR DECLINE? (A/D): A Enter the Item No of new Item: #23077 Entered Item Number Already Exists. RETRY! Enter the Item No of new Item: #23078 Enter the new Item's Price: 7000000 No More Items By Supplier. Would you like to see THE LIST? (Y/N) : Y

Page 57: THE CUBE: Antique Store

7: [11]

SAMPLE INPUT & OUTPUT

_________________________________THE LIST_________________________________ Item No | Name of Item | Age| Cost| #23022 Compass of Peter Tsar The Terrible 140 7000000 #23023 Gustave's Blueprints 120 6000000 #23032 Hitler's Globe 76 3800000 #23058 Katana of Shogan Tokugawa 414 20700000 #23059 Mahatma Gandhi's Spectacles 62 3100000 #23067 Red Barron's Remains 96 4800000 #23076 Silver Claws Of Maharana 74 3700000 #23077 Stallon's Lost Diary 76 3800000 #23078 The Toothpick of Gibralter 45 7000000 #23091 The Pharaoh's Sceptre 124 6200000 See the next 10 items? (Y/N) : N ___________________________[Enter To Continue]____________________________ _____________________________I AM THE MANAGER_____________________________ TO ADD AN ITEM TO THE STORE. 1. From Supplier 2. From Manager. Your Choice (1-2) : 2 How many items to add? : 2 Item To Add (1/2) Enter the Item No of new Item : #23001 Enter the Name of the Item : Boomerang of Alura Enter the Age of the Item : 89 Enter the Item's Price : 6900000 Enter the Item's History : Weapon used by Alura for hunt and battle Item To Add (2/2) Enter the Item No of new Item : #23004 Enter the Name of the Item : Book of Odis Enter the Age of the Item : 550 Enter the Item's Price : 8000000 Enter the Item's History : The book of spells according to Norse Mythology Would you like to see THE LIST? (Y/N) : Y

Page 58: THE CUBE: Antique Store

7: [12]

SAMPLE INPUT & OUTPUT

_________________________________THE LIST_________________________________ Item No | Name of Item | Age| Cost| #23001 Boomerang of Alura 89 6900000 #23004 Book of Odis 550 8000000 #23022 Compass of Peter Tsar The Terrible 140 7000000 #23023 Gustave's Blueprints 120 6000000 #23032 Hitler's Globe 76 3800000 #23058 Katana of Shogan Tokugawa 414 20700000 #23059 Mahatma Gandhi's Spectacles 62 3100000 #23067 Red Barron's Remains 96 4800000 #23076 Silver Claws Of Maharana 74 3700000 #23077 Stallon's Lost Diary 76 3800000 See the next 10 items? (Y/N) : Y #23078 The Toothpick of Gibralter 45 7000000 #23091 The Pharaoh's Sceptre 124 6200000 #23096 Viking's Sledgehammer 168 8400000 ___________________________[Enter To Continue]____________________________

Page 59: THE CUBE: Antique Store

7: [13]

SAMPLE INPUT & OUTPUT

_____________________________I AM THE MANAGER_____________________________ 1. CHANGE THE PASSWORD | Be Safe & Secure. 2. ADD AN ITEM TO THE LIST | More items to add? 3. EDIT AN ITEM ON THE LIST | Make some Changes. 4. DELETE AN ITEM FROM THE LIST | Remove the Unwanted. 5. USE THE CUBE CASHIER | Check. Deposit. Withdraw. 0. EXIT. | Done? Log out Safely. __________________________________________________________________________ Your Choice (0-5): 3 _____________________________I AM THE MANAGER_____________________________ Enter the Item No of the Item to Edit #23032 Which entity do you want to edit? 1. Name 2. Age 3. Cost 4. History Your Choice (1-4) : 1 Enter the new Name: Globe of Adolf Hitler Any more EDITs on this item? (Y/N) : Y Which entity do you want to edit? 1. Name 2. Age 3. Cost 4. History Your Choice (1-4) : 2 Enter the new Age: 81 Any more EDITs on this item? (Y/N) : N Your EDITING has been successful! Would you like to see THE LIST? (Y/N) Y

Page 60: THE CUBE: Antique Store

7: [14]

SAMPLE INPUT & OUTPUT

_________________________________THE LIST_________________________________ Item No | Name of Item | Age| Cost| #23001 Boomerang of Alura 89 6900000 #23004 Book of Odis 550 8000000 #23022 Compass of Peter Tsar The Terrible 140 7000000 #23023 Gustave's Blueprints 120 6000000 #23032 Globe of Adolf Hitler 81 3800000 #23058 Katana of Shogan Tokugawa 414 20700000 #23059 Mahatma Gandhi's Spectacles 62 3100000 #23067 Red Barron's Remains 96 4800000 #23076 Silver Claws Of Maharana 74 3700000 #23077 Stallon's Lost Diary 76 3800000 See the next 10 items? (Y/N) : N ___________________________[Enter To Continue]____________________________ _____________________________I AM THE MANAGER_____________________________

Page 61: THE CUBE: Antique Store

7: [15]

SAMPLE INPUT & OUTPUT

1. CHANGE THE PASSWORD | Be Safe & Secure. 2. ADD AN ITEM TO THE LIST | More items to add? 3. EDIT AN ITEM ON THE LIST | Make some Changes. 4. DELETE AN ITEM FROM THE LIST | Remove the Unwanted. 5. USE THE CUBE CASHIER | Check. Deposit. Withdraw. 0. EXIT. | Done? Log out Safely. __________________________________________________________________________ Your Choice (0-5): 4 _____________________________I AM THE MANAGER_____________________________ Enter the item number of the item you wish to delete. #23058 The Item has been deleted. Would you like to see THE LIST? (Y/N) Y _________________________________THE LIST_________________________________ Item No | Name of Item | Age| Cost| #23001 Boomerang of Alura 89 6900000 #23004 Book of Odis 550 8000000 #23022 Compass of Peter Tsar The Terrible 140 7000000 #23023 Gustave's Blueprints 120 6000000 #23032 Globe of Adolf Hitler 81 3800000 #23059 Mahatma Gandhi's Spectacles 62 3100000 #23067 Red Barron's Remains 96 4800000 #23076 Silver Claws Of Maharana 74 3700000 #23077 Stallon's Lost Diary 76 3800000 #23078 The Toothpick of Gibralter 45 7000000 See the next 10 items? (Y/N) : Y #23091 The Pharaoh's Sceptre 124 6200000 #23096 Viking's Sledgehammer 168 8400000 ___________________________[Enter To Continue]____________________________

Page 62: THE CUBE: Antique Store

7: [16]

SAMPLE INPUT & OUTPUT

_____________________________I AM THE MANAGER_____________________________ 1. CHANGE THE PASSWORD | Be Safe & Secure. 2. ADD AN ITEM TO THE LIST | More items to add? 3. EDIT AN ITEM ON THE LIST | Make some Changes. 4. DELETE AN ITEM FROM THE LIST | Remove the Unwanted. 5. USE THE CUBE CASHIER | Check. Deposit. Withdraw. 0. EXIT. | Done? Log out Safely. __________________________________________________________________________ Your Choice (0-5): 5 _____________________________I AM THE MANAGER_____________________________ Welcome to The Cube Cashier. Choose Among The Options Below: 1. View Balance 2. Deposit 3. Withdraw Your Choice (1-3) :1 The Balance in your Account: 2437783003 Exit Cube Cashier? (Y/N) :N Choose Among The Options Below: 1. View Balance 2. Deposit 3. Withdraw Your Choice (1-3) :3 How much money to withdraw from Account? 7783003 The Balance in your Account: 2430000000 Exit Cube Cashier? (Y/N) : Y

Page 63: THE CUBE: Antique Store

7: [17]

SAMPLE INPUT & OUTPUT

_____________________________I AM THE MANAGER_____________________________ 1. CHANGE THE PASSWORD | Be Safe & Secure. 2. ADD AN ITEM TO THE LIST | More items to add? 3. EDIT AN ITEM ON THE LIST | Make some Changes. 4. DELETE AN ITEM FROM THE LIST | Remove the Unwanted. 5. USE THE CUBE CASHIER | Check. Deposit. Withdraw. 0. EXIT. | Done? Log out Safely. __________________________________________________________________________ Your Choice (0-5): 0 _____________________________I AM THE MANAGER_____________________________ Thank you & Goodbye Manager! You Have been logged out Safely. ___________________________[Enter To Continue]____________________________ __________________________________________________________________________ _________________________________MAIN MENU________________________________ 1. THE LIST | Shows the List of items on Sale. 2. THE HISTORY | Learn more about an Item or Store 3. THE SEARCH | Can't Find what you're looking for? 4. I AM A CUSTOMER | Buy something nice for Yourself. 5. I AM A SUPPLIER | Sell us something We may like. 6. I AM THE MANAGER | A Password Protected Control Centre. 0. EXIT. | Done here? Leave the Online Store. __________________________________________________________________________ Your Choice (0-6): 0 Thank you For Visiting & Come Again Soon!

Page 64: THE CUBE: Antique Store

8: [1]

BIBLIOGRAPHY

COMPUTER SCIENCE WITH C++ SUMITA ARORA 1

2

3

HTTP://CPLUSPLUS.COM

HTTP://TDOCPP.CO.CC

Page 65: THE CUBE: Antique Store

9: [1]

There are a number of possibilities to make this software better. After learning the usage and application of graphics, I plan on further improving the interactive nature of the software. The menu would have clickable buttons rather than typed in choices and by introducing the mouse pointer, selection of those options would be far more convenient. I also intend on introducing selective functionality through user accounts. This would provide more options for suppliers and managers. A Supplier can make an account, send an offer and be updated on the manager’s decision as well. This would be possible only with user accounts where the supplier can be identified by their username. Also, if the store is run by more than one person and each person is assigned a specific task to play, user accounts will be able to divide the manager options accordingly. As of now, its functions are restricted to those of an Antique Store. I plan to generalize it so that it can be used in any type of store allowing the manager to choose which fields and options are most suitable for his store. The next thing would be to encrypt the data files. Presently, the files store the details of the items on sale, the balance of the store and the password to access the manager options. These can be easily accessed using a notepad in windows. To prevent this, the files should be encrypted so that those who do try to read the data will not be able to make sense of it, and making the files Read Only can prevent offenders from changing the information. Unfortunately, this software is mainly just recording changes in the store with transactions. With much further study, I can implement it in the real world. Rather than recording the money moving from one account to another, the software can be made to access the bank accounts and allow the transaction of actual money.

SCOPE FOR FUTURE EXPANSION

Page 66: THE CUBE: Antique Store

NEIL MATHEW

XII B 13 DON BOSCO SCHOOL