User:Aparnanayak

BookModel --- using namespace std; class book { private: string name; string authorname,category; int quantity; float price;
 * 1) include

public: string get_name { return name; } string get_aname { return authorname; } string get_category { return category; } int get_quantity { return quantity; } float get_price { return price; } void set_name(string name) { this->name=name; } void set_aname(string aname) { authorname=aname; } void set_category(string cat) { category=cat; } void set_quantity(int q) { quantity=q; } void set_price(float p) { price=p; } book { name=""; authorname=""; category=""; price=0.0; quantity=0; } book(string name,string aname,string cat,float p, int q) { this->name=name; authorname=aname; category=cat; price=p; quantity=q; } }; ___________________________________________________________________________                  BookSystem ____________________________________________________________________ using namespace std; class bookSystem {	public: bool add_Book(book *b) {		bool b;		b=insertBookinDB(b); return b;	} bool add_Customer(customer *c) {		bool c;		c=insertCustomerinDB(c); return c;	}
 * 1) include
 * 2) include"dbHandler.cpp"
 * 3) include"bookmodel.cpp"

}; ________________________________________________________________________

Customer ________________________________________

class customer {	private: string name; int age; string sex; string address; int contact; public: customer {			name=""; age=0; sex=""; address=""; contact=""; }		customer(string name,int age,string sex,string address,int contact) {			this->name=name; this->age=age; this->sex=sex; this->address=address; this->contact=contact; }		string get_name {			return name; }		int get_age {			return age; }		string get_sex {			return sex; }		string get_address {			return address; }		int get_contact {			return contact; }		void set_name {			this->name=name; }		void set_age {			this->age=age; }		void set_sex {			this->sex=sex; }		void set_address {			this->address=address; }		void set_contact {			this->contact=contact; } };

________________________________________________________________

Customer_UI

using namespace std;
 * 1) include
 * 2) include "customermodel.cpp"
 * 3) include "tarzanmenu.cpp"

class customerUI {	private: string cname; int cage; string csex; string caddress; long cphone; string cpwd; public: customer* getCustomerDetails {		bool valid; char choice; customer *c; valid=validateCustomerDetails; do {			if(valid==true) {				c=new customer(cname,cage,csex,caddress,cphone,cpwd); }			else {				cout<<"\n details entered are incorrect"; cout<<"\n do u want to enter again"; cin>>choice; if(choice=='y'||choice=='Y') {					valid=validateCustomerDetails; c=new customer(cname,cage,csex,caddress,cphone,cpwd); }				else exit(0); }		}while(valid==false); return c;	} bool validateCustomerDetails {		bool b=false; cout<<"\n enter customer name"; cin>>cname; cout<<"\n enter your age"; cin>>cage; cout<<"\n enter sex"; cin>>csex; cout<<"\n enter your address"; cin>>caddress; cout<<"\n enter your contact no"; cin>>cphone; cout<<"\n enter password"; cin>>cpwd; if( cage>0 && (csex=="male"||csex=="female") && (cphone >10000000 && cphone < 99999999)) {			b=true; }		else {			cout<<"\n enter valid age,sex or contact no."; b=false; }		return b;	}

void notifySuccessfulRegistration(customer c)	{ cout<<"customer added succesfully"; cout<<"followin are the details"; cout<<"\n customer name:"<<c.get_name<<"\nage:"<<c.get_age<<"\nsex"<<c.get_sex<<"\n address:"<<c.get_address<<"contact no:"<<c.get_contact; cout<<"this is ur login id"; c.get_Id; display_mainmenu; }	void notifyRegistrationFailure {		cout<<"failed to add details"; display_mainmenu; } }; -- customercontroller ___________________________________

using namespace std; class customer_controller {	bookSystem bs; public: void registerCustomer {			string message; bool success; customer_UI ui; customer c1=ui.getCustometerDetails; success=bs.add_customer(c1); if(success=true) {			ui.notifySuccessfulRegistration(c1); }			else ui.notifyRegistrationFailure; }
 * 1) include
 * 2) include"customermodel.cpp"
 * 3) include"booksystem.cpp"
 * 4) include"customer_UI.cpp"

___________________________________________________

customermodel ________________________________________________________

using namespace std; class customer {	private: string name; int age; string sex; string address; long contact; string pwd; int id;
 * 1) include

public: customer {			name=""; age=0; sex=""; address=""; contact=00000000; pwd=""; }		customer(string name,int age,string sex,string address,long contact,string pwd) {			this->name=name; this->age=age; this->sex=sex; this->address=address; this->contact=contact; this->pwd=pwd; }		string get_name {			return name; }		int get_age {			return age; }		string get_sex {			return sex; }		string get_address {			return address; }		long get_contact {			return contact; }		void set_name(string name) {			this->name=name; }		void set_age(int age) {			this->age=age; }		void set_sex(string sex) {			this->sex=sex; }		void set_address(string address) {			this->address=address; }		void set_contact(long contact) {			this->contact=contact; }		int get_Id {			return id; }		void set_Id(int id) {			this->id=id; }		string get_pwd {			return pwd; }		void set_pwd(string pwd) {			this->pwd=pwd; }

};

/*int main {	customer c("deeksha",20,"female","delhi",23456785,"manali"); cout<<c.get_name; cout<<c.get_age; cout<<c.get_sex; cout<<c.get_address; cout<<c.get_contact; cout<<c.get_pwd; }*/ ____________________________________________________________

DBhandler _________________________________________________________

using namespace std; EXEC SQL BEGIN DECLARE SECTION; char con[30]="c2708@oracle"; char pwd[30]; //book variables int bookid=0; char bname[30],aname[30],cat[20]; int quant; float price; //customer variables int id=101; char cname[30],csex[30],caddress[30],cpwd[30]; int cage,cphone; EXEC SQL END DECLARE SECTION; EXEC SQL INCLUDE SQLCA; class dbHandler { public: void connectCheck {       strcpy(pwd,"tcs"); EXEC SQL CONNECT :con IDENTIFIED BY :pwd; if(sqlca.sqlcode==0) {               cout<<"connected"; }       if(sqlca.sqlcode<0) {               cout<<"Error in connect"; } } bool insertBookinDB(book *obj) {		bool b;       bookid++; price=obj->get_price; quant=obj->get_quantity; strcpy(bname,(obj->get_name).c_str); strcpy(aname,(obj->get_aname).c_str); strcpy(cat,(obj->get_category).c_str); EXEC SQL INSERT into BOOK values(:bookid,:bname,:aname,:cat,:price,:quant); if(sqlca.sqlcode==0) {               cout<<"Data inserted"; }       if(sqlca.sqlcode<0) {               cout<<"Error in Insert"; } } bool insertCustomerinDB(customer *obj) {	bool b;	id++; strcpy(cname,(obj->get_name).c_str); cage=obj->get_age; strcpy(csex,(obj->get_sex).c_str); strcpy(caddress,(obj->get_address).c_str); cphone=obj->get_contact; strcpy(cpwd,(obj->get_pwd).c_str); EXEC SQL INSERT into CUSTOMER values(:id,:cname,:cage,:csex,:caddress,:cphone,:cpwd); if(sqlca.sqlcode==0) {		cout<<"data inserted"; }	if(sqlca.sqlcode<0) {		cout<<"error in insert"; } }
 * 1) include
 * 2) include"bookmodel.cpp"
 * 3) include"customermodel.cpp"

}; int main { book *b=new book("learning in c++","robert lafore","c++",120.00,3); customer *c=new customer("deeksha",20,"female","delhi",23456712,"manali"); dbHandler d; d.connectCheck; d.insertBookinDB(b); d.insertCustomerinDB(c); EXEC SQL COMMIT WORK RELEASE; } ____________________________________________________________________________    menu

__________________________________________

using namespace std; void display_mainmenu { int ch; char c; do { cout<<"\tTARZAN BOOK STORE"; cout<<"\n1.Log In"; cout<<"\n2.Register"; cout<<"\n3.view book"; cout<<"\n Enter your choice 1,2,3:  "; cin>>ch; switch(ch) {	case 1: //log_in; break; case 2: //registration; break; case 3: //view_book; break; default: cout<<"\nWrong choice Enter again: "; } cout<<"do you want to continue (y/n)"; cin>>c; }while(c=='y'||c=='Y'); } int main { display_mainmenu; }
 * 1) include