图书订购系统

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

//图书订购系统

#include

#include

using namespace std;

#include"buy.h"

#include"book.h"

const int x=20;

class order{

public:

order();

void setbuyid(int b_id);

void buy_one_book(string b_id);

void display();

private:

static int ordercount;

int orderID;

int buyerID;

int listcount;

string orderlist[20];

};

order::order(){

buyerID=0;

ordercount++;

orderID=ordercount;

listcount=0;

}

void order::setbuyid(int b_id){

buyerID=b_id;

}

void order::buy_one_book(string b_id){

orderlist[listcount]=b_id;

listcount++;

}

void order::display(){

cout<<"\n订单信息\n\n"

<<"订单号:"<

<<"购书人编号:"<

<<"购买图书编号:"<

for(int i=0;i

cout<<"\t"<

cout<

}

int order::ordercount=0;

int main(){

int buyerid,flag,j=0;

book* c[2];

common b1("黄潮州",1,"宁都",0);

vip b2("肖心远",2,"南昌",0.6,0);

member b3("谢小汶",3,"于都",5,0);

order ol[20];

buyer* b[3]={&b1,&b2,&b3};

book c1("C1","C++ programe","谭浩强","清华",35);

book c2("C2","data structure","徐天风","北大",20);

c[0]=&c1;

c[1]=&c2;

cout<<"购书人信息:\n\n";

for(int i=0;i<2;i++)

b[i]->display();

cout<<"\n图书信息:\n\n";

for(i=0;i<3;i++)

c[i]->display();

while(j<2){

cout<<"\n\n"

<<"请输入购书编号:";

cin>>buyerid;

flag=0;

for(i=0;i<3;i++)

if(b[i]->getid()==buyerid){

flag=1;

break;

}

if(!flag)

cout<<"编号不存在!"<

else{

b[i]->setpay(c[0]->getprice());

b[i]->setpay(c[1]->getprice());

cout<getpay()<<"\n\n";

ol[j].setbuyid(b[i]->getid());

ol[j].buy_one_book(c[0]->getbook_ID());

ol[j].buy_one_book(c[1]->getbook_ID());

ol[j].display();

j++;

}

}

return 0;

}

//book.h

class book{

protected:

string book_ID;

string book_name;

string author;

string publish;

double price;

public:

book();

book(string b_id,string b_n,string au,string pu,double pr);

void display();

string getbook_ID();

string getbook_name();

string getauthor();

string getpublish();

double getprice();

};

book::book(string b_id,string b_n,string au,string pu,double pr){ book_ID=b_id;

book_name=b_n;

author=au;

publish=pu;

price=pr;

}

相关文档
最新文档