模拟网上购书的结帐功能项目说明书2.docx

上传人:b****2 文档编号:1145061 上传时间:2022-10-17 格式:DOCX 页数:13 大小:42.60KB
下载 相关 举报
模拟网上购书的结帐功能项目说明书2.docx_第1页
第1页 / 共13页
模拟网上购书的结帐功能项目说明书2.docx_第2页
第2页 / 共13页
模拟网上购书的结帐功能项目说明书2.docx_第3页
第3页 / 共13页
模拟网上购书的结帐功能项目说明书2.docx_第4页
第4页 / 共13页
模拟网上购书的结帐功能项目说明书2.docx_第5页
第5页 / 共13页
点击查看更多>>
下载资源
资源描述

模拟网上购书的结帐功能项目说明书2.docx

《模拟网上购书的结帐功能项目说明书2.docx》由会员分享,可在线阅读,更多相关《模拟网上购书的结帐功能项目说明书2.docx(13页珍藏版)》请在冰豆网上搜索。

模拟网上购书的结帐功能项目说明书2.docx

模拟网上购书的结帐功能项目说明书2

 

《面向对象程序设计基础》

 

项目设计说明书

 

项目:

模拟网上购书

的结账系统

专业:

软件工程

班级:

16级1班

学号:

16044115

姓名:

李泽

 

哈尔滨学院·信息工程学院

一、功能要求

模拟实现网上购书的结账功能。

使用C++,实现图书信息的输入、输出,购书人信息的输出、购书账单的结算、保存等功能。

二、设计要求

1.设计类。

包含:

(1)定义基类buyer,其中含有数据成员:

姓名、购书人编号、地址等。

(2)定义基类buyer的派生类:

普通人、会员、贵宾。

要求会员类增加数据成员会员级别,贵宾类增加数据成员折扣率。

(3)定义书类book,其中含有数据成员:

书号、书名、作者、定价等。

2.系统实现以下相应的各项功能:

(1)图书信息的输入、输出;

(2)购书人信息的输出;

(3)购书账单的结算;

(4)购书信息的保存。

3.其它要求:

(1)使用构造函数、析构函数和成员函数;

(2)使用友元、继承;

(3)使用文件保存;

(4)使用适当的注释进行说明;

(5)允许适当地增加其它功能。

三、全部的程序源代码(有相应注释)

//buy.h

classbuyer

{

protected:

stringname;

intbuyerID;

stringaddress;

doublepay;

public:

buyer();

buyer(stringn,intb,stringa,doublep);

stringgetbuyname();

stringgetaddress();

doublegetpay();

intgetid();

virtualvoiddisplay()=0;

virtualvoidsetpay(double=0)=0;

};

classmember:

publicbuyer

{

intleaguer_grade;

public:

member(stringn,intb,intl,stringa,doublep):

buyer(n,b,a,p)

{

leaguer_grade=l;

}

voiddisplay();

voidsetpay(doublep);

};

classhonoured_guest:

publicbuyer

{

doublediscount_rate;

public:

honoured_guest(stringn,intb,doubler,stringa,doublep):

buyer(n,b,a,p)

{

discount_rate=r;

}

voiddisplay();

voidsetpay(doublep);

};

classlayfolk:

publicbuyer

{

public:

layfolk(stringn,intb,stringa,doublep):

buyer(n,b,a,p)

{}

voiddisplay();

voidsetpay(doublep);

};

buyer:

:

buyer()

{

name="";

buyerID=0;

address="";

pay=0;

}

buyer:

:

buyer(stringn,intb,stringa,doublep)

{

name=n;

buyerID=b;

address=a;

pay=p;

}

doublebuyer:

:

getpay()

{

returnpay;

}

stringbuyer:

:

getaddress()

{returnaddress;}

stringbuyer:

:

getbuyname()

{returnname;

}

intbuyer:

:

getid()

{returnbuyerID;}

//////////////////////////////////////////////

voidmember:

:

display()

{

cout<<"购书人姓名:

"<

cout<<"购书人编号:

"<

cout<<"购书人为会员,级别:

"<

cout<<"购书地址:

"<

}

//////////////////////////////////////////////

voidmember:

:

setpay(doublep)

{

if(leaguer_grade==1)

pay=.95*p+pay;

elseif(leaguer_grade==2)

pay=.90*p+pay;

elseif(leaguer_grade==3)

pay=.85*p+pay;

elseif(leaguer_grade==4)

pay=.8*p+pay;

elseif(leaguer_grade==5)

pay=.7*p+pay;

else

cout<<"级别错误!

";

}

///////////////////////voidmember:

:

display()

voidhonoured_guest:

:

display()

{

cout<<"购书人姓名:

"<

cout<<"购书人编号:

"<

cout<<"购书人为贵宾,折扣率为:

"<

cout<<"购书地址:

"<

}

voidhonoured_guest:

:

setpay(doublep)

{

pay=pay+(1-discount_rate)*p;

}

voidlayfolk:

:

display()

{

cout<<"购书人姓名:

"<

cout<<"购书人编号:

"<

cout<<"购书人为普通人:

"<<"\n";

cout<<"购书地址:

"<

}

voidlayfolk:

:

setpay(doublep)

{

pay=pay+p;

}

 

//book.h

classbook

{

protected:

stringbook_ID;

stringbook_name;

stringauthor;

stringpublishing;

doubleprice;

public:

book()

{

book_ID="";

book_name="";

author="";

publishing="";

price=0;

}

book(stringb_id,stringb_n,stringau,stringpu,doublepr)

{

book_ID=b_id;

book_name=b_n;

author=au;

publishing=pu;

price=pr;

}

voiddisplay()

{

cout<<"书号:

"<

cout<<"书名:

"<

cout<<"作者:

"<

cout<<"出版社:

"<

cout<<"定价:

"<

}

stringgetbook_ID()

{

returnbook_ID;

}

stringgetbook_name()

{

returnbook_name;

}

stringgetauthor()

{

returnauthor;

}

stringgetpublishing()

{

returnpublishing;

}

doublegetprice()

{

returnprice;

}

};

//strclass.h

#include"string.h"

classstring

{

friendostream&operator<<(ostream&S,conststring&Str);

friendistream&operator>>(istream&S,string&Str);

public:

string();

string(conststring&Str);

voidoperator=(conststring&Str);

~string();

string(char*p);

private:

shortm_Length;

char*m_Date;

};

string:

:

string()

{

m_Length=1;

m_Date=newchar[m_Length];

memcpy(m_DATE,"",m_Length);

};

string:

:

string(conststring&Str)

{

m_Length=Str.m_Length;

m_Date=newchar[m_Length];

memcpy(m_Date,Str.m_Date,m_Length);

};

string:

:

string(char*p)

{

m_Length=strlen(p)+1;

m_Date=newchar[m_Length];

memcpy(m_Date,p,m_Length);

};

voidstring:

:

operator=(conststring&Str)

{

if(&Str!

=this)

{

delete[]m_Date;

m_Length=Str.m_Length;

m_Date=newchar[m_Length];

memcpy(m_Date,Str.m_Date,m_Length);

}

return;

};

string:

:

~string()

{delete[]m_Date;

};

ostream&operator<<(ostream&S,conststring&Str)

{

shorti;

for(i=1;i

S<

returnS;

};

istream&operator>>(istream&S,string&Str)

{

constshortBUFLEN=256;

charBuf[BUFLEN];

memset(Buf,0,BUFLEN);

if(S.peek()=='\n')

S.ignore();

S.getline(Buf,BUFLEN,'\n');

Str=Buf;

returnS;

};

//buy_book.cpp

#include

#include

usingnamespacestd;

#include"buy.h"

#include"book.h"

classo

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > IT计算机 > 计算机软件及应用

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1