图书馆管理系统

#include <iostream>
using namespace std;
class Book
{
private:
    string name;//图书名
    string writer;//图书作者
    string public_name;//图书出版社
    double price;//图书价钱
    int number;//图书数量
    int no;//图书号
public:
    void set_book( );//图书信息
    void borrow();//借书
    void restore();//还书
    void print( );//借阅信息
    void set_NO(int n); //修改书号
    int get_NO( ); //添加书号
};
void Book::set_book()//图书信息
{
    string na,w,pn;
    double p;
    int nu,n,i,count=0;
    cout<<"请输入图书名:";
    cin>>na;
    name=na;
    cout<<"请输入作者:";
    cin>>w;
    writer=w;
    cout<<"请输入图书出版社:";
    cin>>pn;
    public_name=pn;
    cout<<"请输入图书价钱:";
    cin>>p;
    price=p;
    cout<<"请输入图书数量:";
    cin>>nu;
    number=nu;
    cout<<"请输入图书号:";
    cin>>n;
    no=n;
}
void Book::borrow()//借书
{
    cout<<"请输入要借阅的图书名:";
    cin>>name;
    number--;

}
void Book::restore()//还书
{
    cout<<"请输入要归还的图书名:";
    cin>>name;
    number++;
}
void Book::print()//借阅信息
{
    cout<<"name: "<<name<<endl;
    cout<<"writer: "<<writer<<endl;
    cout<<"public name: "<<public_name<<endl;
    cout<<"price: "<<price<<endl;
    cout<<"number: "<<number<<endl;
    cout<<"NO: "<<no<<endl<<endl;
}
void Book::set_NO(int n)
{
    no=n;
}
int Book::get_NO( )
{
    return no;
}
int main( )
{
    int n;
    Book book;
    book.set_book();
    book.print();
    book.borrow();
    book.print();
    book.restore();
    book.print();
    cout<<"请输入要修改的图书编号:";
    cin>>n;
    book.set_NO(n);
    book.print();
    cout<<"修改后的图书编号为:" <<book.get_NO()<<endl;
    return 0;
}


输出结果:

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值