User:Vivek.balloo
- include<iostream>
- include"customer.h" customer
using namespace std;
//Defination of constructor
customer :: customer() {
this->icustomerId=0; this->szcustomerName="xxx"; this->iage=0; this->csex='m'; this->szaddress="Jahanum"; this->icontactNumber=0;
}
customer :: customer(int icustomerId,string szcustomerName,int iage,char csex,string szaddress,unsigned long icontactNumber) {
this->icustomerId=icustomerId; this->szcustomerName=szcustomerName; this->iage=iage; this->csex=csex; this->szaddress=szaddress; this->icontactNumber=icontactNumber;
}
//Defination of setter function:
void customer :: setCustomerId(int icid) { this->icustomerId=icid; }
void customer :: setCustomerName(string szcname) { this->szcustomerName=szcname; }
void customer :: setAge(int iage) { this->iage=iage; }
void customer :: setSex(char csex) { this->csex=csex; }
void customer :: setAddress(string szaddr) { this->szaddress=szaddr; }
void customer :: setContactNumber(unsigned long inum) { this->icontactNumber=inum; }
//Defination of Getter functions:
int customer :: getCustomerId() { return(this->icustomerId); }
string customer :: getCustomerName() { return(this->szcustomerName); }
int customer :: getAge() { return(this->iage); }
char customer :: getSex() { return(this->csex); }
string customer :: getAddress() { return(this->szaddress); }
unsigned long customer :: getContactNumber() { return(this->icontactNumber); }
//Defination of member function: display()
void customer :: display() {
cout<<"\nCustomer Id= "<<this->icustomerId; cout<<"\nCustomer Name= "<<this->szcustomerName; cout<<"\nCustomer Age= "<<this->iage; cout<<"\nCustomer Gender= "<<this->csex; cout<<"\nCustomer Address= "<<this->szaddress; cout<<"\nCustomer Contact number= "<<this->icontactNumber<<"\n\n";
}controller
- include<iostream>
- include<vector>
- include"customercontroller.h"
- include"tarzanutility.h"
- include"customer.h"
- include"tarzanutilitycontroller.h"
//using namespace std;
void customercontroller :: initiateLogin() { customerui custui; tarzanutility util; tarzanutilitycontroller tuc; bookcontroller bookcontrolobject; vector<loginDetails> vld=custui.getLoginDetails(); /*for(int i=0;i<vld.size();i++) { cout<<"\nUsername: "<<vld.at(i).szuserId; cout<<"\nPassword: "<<vld.at(i).szpassword<<"\n"; }*/ int iloginFlag=util.validateLoginDetailsUtility(vld); if(iloginFlag!=0)
{
cout<<"\n------YOU ARE LOGGED IN SUCCESSFULLY------";
if(iloginFlag==1)
{
cout<<"\n------YOU ARE LOGGED IN SUCCESSFULLY------"; tuc.initiateAdminMenu();
}
if(iloginFlag!=1) { int loopstatus=1; customer custobj=util.getCustomerDetails(iloginFlag); while(loopstatus) { int choice=custui.displayCustomerHomeScreen(custobj); switch(choice) { case 1: { //the search process-----------Gunpreet Singh Kohli----- vector<int> retval; book obj; retval=bookcontrolobject.initiateSearchProcessRegistered(obj); cout<<"\nReturned back from the book controller and displaying the bbok details";
cout<<"Book id\t="<<obj.getBookId()<<"\tBook name\t"<<obj.getBookName()<<"quantity=";//<<retval[2]; getchar();
int optionselected=retval[0]; if(optionselected==1) { //cout<<"\nInside The customercontroller....option 1 selected--------and going to customer home screen";
//getchar();
customer cust1=util.getCustomerDetails(iloginFlag);
cout<<"\nCustomer name"<<cust1.getCustomerName();
getchar(); int quanthar=retval[2]; cout<<"\nCheck poirnt"<<quanthar ; getchar();
mybook mbObj;
mbObj.setCustomerObject(cust1);
mbObj.setBookObject(obj); mbObj.setQuantityOrdered(quanthar);
util.addMyBookDetails(mbObj); cout<<"\nLast check point"; getchar();
break; } else if(optionselected==2) { cout<<"\nInside the customercontroller......option 2 selected";
} else { cout<<"\nInside the customer controller option 3 selected"; } //bookcontrolobject.getCustomerSearchExtentionOptions(); break; //------------For Search Process Gunpreet----------- } case 2: { //option to display mybooklist // cout<<"\nSelect option 2"; // getchar(); tarzanutility obj; vector<mybook> mybooklist; int customerid=custobj.getCustomerId(); mybooklist=obj.getCustomerMyBookList(customerid); vector<mybook>::iterator itr; for(itr=mybooklist.begin();itr!=mybooklist.end();itr++) { itr->setCustomerObject(custobj); } //cout<<"\nReturned After fetching the mybook list"; custui.showCustomerMyBookList(mybooklist);
break;
}
case 3:
{
initiateCustomerPurchase(custobj);
//option to purchase books...
break;
}
case 4:
{
//option to update my book details
//cout<<"\nSelect option 5"; customer custObj,custObj1; custObj=util.getCustomerDetails(iloginFlag); cout<<"\nExisting Customer Details are : \n"; custObj.display();
custObj1=custui.getCustomerDetails(); custObj1.setCustomerId(iloginFlag); int iupdateFlag=util.updateCustomerDetails(custObj1);
if(iupdateFlag!=0) { cout<<"\n------Customer Details Succesfully Update------"; custObj=util.getCustomerDetails(iloginFlag);
cout<<"\nCustomer Details after updation are : \n";
custObj.display(); } else { cout<<"\n------Error In Updating Customer Details-------\n"; getchar();
}
break; } case 5: { //option to log out... loopstatus=0; break; } default: { cout<<"\nIncorrect Option Select......Please select again..."; getchar(); } } } } else { //else part to show the admin home screen..... }
}
else { cout<<"\n------INVALID LOGIN DETAILS-------\n"; getchar(); } }
void customercontroller :: initiateCustomerRegistration()
{ customerui custui; tarzanutility util; int signUpFlag=1; do { signUpFlag=1; customer custObj=custui.getCustomerDetails(); int iregisterFlag=util.addCustomerDetails(custObj); if(iregisterFlag!=0) { system("clear"); getchar(); cout<<"\n------CUSTOMER REGISTERED SUCCESFULLY------"<<"\n\nNew Customer Id generated is: "<<iregisterFlag; vector<signUpDetails> vld=custui.getSignUpDetails(); vld[vld.size()-1].setCustomerId(iregisterFlag); cout<<"$$$$$$$$ "<<vld[vld.size()-1].getCustomerId(); int signUpFlag=util.addSignUpDetails(vld);
} else { cout<<"\n------CUSTOMER REGISTERATION FAILED-------\n"; getchar(); } }while(signUpFlag==0); }
/* int main() {
customerController custController; custController.initiateLogin();
}
- /
void customercontroller::initiateCustomerPurchase(customer customerobject) { tarzanutility obj;
vector<mybook> mybooklist;
customerui custui;
int customerid=customerobject.getCustomerId(); mybooklist=obj.getCustomerMyBookList(customerid); vector<mybook>::iterator itr; for(itr=mybooklist.begin();itr!=mybooklist.end();itr++) { itr->setCustomerObject(customerobject); } // cout<<"\nReturned After fetching the mybook list"; custui.showCustomerMyBookList(mybooklist);
vector<int>returnval; string carddetails; returnval=custui.displayCustomerPurchaseOptions(mybooklist,carddetails); //cout<<"\nThe Card details entered are\t"<<carddetails; //getchar(); if(returnval[0]==1) { tarzanutility utilobj; int mybooklistindex=returnval[2]-1; mybook passingobject=mybooklist[mybooklistindex]; int quantity=returnval[2]; string paymentmode; if(returnval[3]==1) { paymentmode="Credit Card"; } else { paymentmode="Debit Card"; } utilobj.performCustomerBookPurchase(passingobject,quantity,carddetails,paymentmode); }
} customer ui
#include<iostream>
- include<vector>
- include"customerui.h"
- include"customer.h"
- include"mybook.h"
using namespace std;
vector<loginDetails> customerui :: getLoginDetails() { vector<loginDetails> vectorObj=showLoginScreen(); return(vectorObj); }
vector<loginDetails> customerui :: showLoginScreen() { vector<loginDetails> loginVector; char uid[30],pswd[30]; cout<<"\nEnter ur user-id: "; cin>>uid; //cout<<"\nEnter ur password: "; strcpy(pswd,getpass("Enter ur password: ")); loginDetails ld(uid,pswd); loginVector.push_back(ld); return(loginVector); }
vector<signUpDetails> customerui :: getSignUpDetails() { vector<signUpDetails> vectorObj=showSignUpScreen(); return(vectorObj); }
vector<signUpDetails> customerui :: showSignUpScreen() { vector<signUpDetails> loginVector; signUpDetails ld; char uid[30],pswd[30],pswd1[30]; bool signUpFlag;
do { signUpFlag=true; cout<<"\n\n----Choose Login-Id and Password for a new account in Tarzan Pustak Bhandar----"; cout<<"\n\nEnter a login-id: "; cin>>uid; //cout<<"\nEnter ur password: "; strcpy(pswd,getpass("Enter a password: ")); strcpy(pswd1,getpass("Re-enter the password again: ")); if(strcmp(pswd,pswd1)==0) { ld.setUserId(uid); ld.setPassword(pswd); loginVector.push_back(ld); } else { cout<<"\n\nPassword does not match...Enter again :\n"; signUpFlag=false; } }while(signUpFlag==false); return(loginVector); }
customer customerui :: getCustomerDetails() { customer custObj=showCustomerRegistrationScreen(); // bool registerFlag=validateCustomerDetails(custObj); return(custObj); }
customer customerui :: showCustomerRegistrationScreen() { customer custObj; string szname,szaddress; bool validFlag=true; char nm[30],addr[30]; int iage; unsigned long ldnum; char csex; do { validFlag=true; getchar(); cout<<"$-----------CUSTOMER REGISTRATION SCREEN------------$\n\n"; cout<<"\nEnter name : "; getline(cin,szname); cout<<"Enter age : "; cin>>iage; if(iage<=5 || iage>=100) { validFlag=false; cout<<"\nInvalid age....\n"; } cout<<"Enter gender(M/F) : "; cin>>csex; if(csex=='m' || csex=='M' || csex=='f' || csex=='F') {//cout<<"\nGender is: "<<csex; } else { validFlag=false; cout<<"\nInvalid gender.....\n"; } getchar(); cout<<"Enter address : "; getline(cin,szaddress); cout<<"Enter contact number : "; cin>>ldnum; if(ldnum<0 || ldnum>999999999) { validFlag=false; cout<<"\nInvalid phone number...\n"; } if(validFlag==false) { cout<<"\nInvalid Customer Details....Enter again : \n\n"; getchar(); } }while(validFlag==false);
custObj.setCustomerId(0); custObj.setCustomerName(szname); custObj.setAge(iage); custObj.setSex(csex); custObj.setAddress(szaddress); custObj.setContactNumber(ldnum);
return(custObj); }
int customerui::displayCustomerHomeScreen(customer &obj)
{
system("clear");
//displyin the customer home scree...
int choice;
string name=obj.getCustomerName();
cout<<">>>>>>>>>>>>>>>\t Welcome "<<name<<"To Tarzan Pustak Bhandaar";
cout<<"\n \n \n \n";
cout<<"\nMenu";
cout<<"\n1.Search";
cout<<"\n2.Check My Books";
cout<<"\n3.Purchase Books";
cout<<"\n4.Update Details";
cout<<"\n5.Log Out";
cout<<"\nPlease select the option";
cin>>choice;
return choice;
}
void customerui::showCustomerMyBookList(vector<mybook> mybooklist)
{
getchar();
system("clear");
//cout<<"\nDisplaying the mybook list......";
int snumber=0;
cout<<"\nBook name---->"<<mybooklist[0].getBookObject().getBookName();
cout<<"\nBook Author----->"<<mybooklist[0].getBookObject().getBookAuthorName();
cout<<"\n---------------------------------------------------------------------------------------------------------------------";
cout<<"\nSerial Number\tBook Name\tAuthor Name\tCategory\t Add Date\t Quantity Ordered";
cout<<"\n---------------------------------------------------------------------------------------------------------------------";
int size=mybooklist.size();
for(int i=0;i<size;i++)
{
cout<<"\n"<<(i+1)<<"\t"<<mybooklist[i].getBookObject().getBookName()<<"\t"<<mybooklist[i].getBookObject().getBookAuthorName()<<mybooklist[i].getBookObject().getBookCategory()<<mybooklist[i].getAddDate()<<"\t"<<mybooklist[i].getQuantityOrdered();
}
getchar();
}
vector<int> customerui::displayCustomerPurchaseOptions(vector<mybook> mybooklist,string &carddetails)
{
//cout<<"\nInside the customer purchase options function---";
getchar();
vector<int> searchoptions;
int loopstatus=1,choice;
int serial;
int quantity;
int returnvalue;
int once=0;//variable to exit the outer while loop when option to purchase has been selected and the userhas entered the valid input for the serial no. and the quanitiy;
while(loopstatus)
{
if(once==1)
{
break;
}
cout<<"\n1.Purchase";
cout<<"\n2.Exit";
cin>>choice;
switch(choice)
{
case 1:
{
searchoptions.push_back(choice);
int mybooklistcount=mybooklist.size();
// cout<<"\nThe booklistcount=="<<mybooklistcount;
int iloops=1;
while(iloops)
{
cout<<"\nSelect the serial no. of the book to purchase"; cin>>serial; if(serial<0) { cout<<"\nThe serial number should be positivei......Please Enter the serial number again....";
} else if(serial>mybooklistcount) { cout<<"\nInvalid Serial Number..Please Enter again"; } else { iloops=0; } } searchoptions.push_back(serial);
int iloop=1; while(iloop) { cout<<"\Enter the quantity to purchase"; cin>>quantity;
int quantlist=mybooklist[serial-1].getQuantityOrdered(); if(quantity<0) { cout<<"\nQuantity cannot be negative"; } else if(quantity>quantlist) { cout<<"\nQuantity cannot be more than the value reserved"; } else { break; } }
searchoptions.push_back(quantity); int cardchoice; iloops=1; while(iloops) { cout<<"\nEnter the payment mode----\t1.credit card\t2.Debit Card"; cin>>cardchoice; if((cardchoice==1)||(cardchoice==2)) { iloops=0;
} else { cout<<"\nInvalid Option S electd....Please Enter Again..."; } } searchoptions.push_back(cardchoice); iloops=1; while(iloops) {
cout<<"\nEnter the card details"; cin>>carddetails; string tempstr=carddetails; if((carddetails.size()!=8)||(carddetails=="0000000000000000")) { cout<<"\nInvalid Card details....Please Enter again"; } else { iloops=0; } } once=1;
break; } case 2: { searchoptions.push_back(choice);
loopstatus=0; break; } default: { cout<<"\nIncorrect option selected.....Please Enter again"; } } } return searchoptions; } /* int main()
{ customerui custui; vector<loginDetails> ld=custUI.getSignUpDetails(); cout<<"username: "<<ld[ld.size()-1].szuserId; cout<<"password: "<<ld[ld.size()-1].szpassword; }
- /
- ifndef _customer_h
- define _customer_h
- include<iostream>
using namespace std;
class customer
{
private: int icustomerId; string szcustomerName; int iage; char csex; string szaddress; unsigned long icontactNumber; public: customer(); customer(int icustomerId,string szcustomerName,int iage,char csex,string szaddress, unsigned long icontactNumber); void setCustomerId(int icid); void setCustomerName(string szcname); void setAge(int iage); void setSex(char csex); void setAddress(string szaddr); void setContactNumber(unsigned long inum);
int getCustomerId(); string getCustomerName(); int getAge(); char getSex(); string getAddress(); unsigned long getContactNumber();
void display();
};
- endif
#ifndef _customercontroller_h
- define _customercontroller_h
- include<iostream>
- include<vector>
- include"customerui.h"
- include"bookcontroller.h"
- include"bookui.h"
//using namespace std;
class customercontroller
{
public: void initiateLogin();
void initiateCustomerRegistration(); void initiateCustomerPurchase(customer); void initiateCustomerDetailsUpdate();
};
- endif
- ifndef _customerui_h
- define _customerui_h
- include<iostream>
- include<vector>
- include"structs.h"
- include"customer.h"
- include"mybook.h"
- include"book.h"
using namespace std;
class customerui {
public: vector<loginDetails> getLoginDetails();
vector<loginDetails> showLoginScreen();
customer getCustomerDetails(); customer showCustomerRegistrationScreen();
bool validateCustomerDetails(customer);
vector<signUpDetails> getSignUpDetails();
vector<signUpDetails> showSignUpScreen();
int displayCustomerHomeScreen(customer&); void showCustomerMyBookList(vector<mybook>); vector<int> displayCustomerPurchaseOptions(vector<mybook>,string&); };
- endif
main ui
- ifndef _mainui_h
- define _mainui_h
- include<iostream>
using namespace std;
void displayWelcomeMenu() {
cout<<"\n$---------WELCOME TO TARZAN PUSTAK BHANDAR-----------$"; cout<<"\n1.Login"; cout<<"\n2.Register as a new customer"; cout<<"\n3.Search books"; cout<<"\n4.Exit"; cout<<"\nEnter your choice--> ";
}
int getOption() {
int choice; displayWelcomeMenu(); cin>>choice; return(choice);
}
//-------------------------Tera mera partitions............................. void displayAdminMenu() {
cout<<"\n$---------WELCOME TO TARZAN PUSTAK BHANDAR-----------$"; cout<<"\n $-----------ADMIN MENU-----------$"; cout<<"\n\n 1.Search book."; cout<<"\n 2.Add a new book."; cout<<"\n 3.Update book details for an existing book"; cout<<"\n 4.Reports Generation."; cout<<"\n 5.Update Admin Details."; cout<<"\n 6.Logout."; cout<<"\nEnter your choice--> ";
}
int getAdminOption() {
int choice; displayAdminMenu(); cin>>choice; return(choice);
}
//-----------------------------Tera mera partition khatam--------------------------------
- endif