/*
*Copyright (c)2014,烟台大学计算机与控制工程学院
*All rights reserved.
*文件名称:zzz.cpp
*作 者 张伟建
*完成日期:2015年3月17日
*版 本 号:v1.0
*
*问题描述:借阅图书
*输入描述:
*输出描述:
*/
#include <iostream>
#include <cstring>
using namespace std;
class Book
{
private:
char name[20];
char writer[5];
char public_name[10];
double price;
int number;
int No;
public:
void setbook(char *na,char *w,char *pub,double p,int num,int no);
void set_No(int n);
int get_No();
void borrow();
void restore();
void print( );
};
void Book::setbook(char *na,char *w,char *pub,double p,int num,int no)
{
strcpy(name,na);
strcpy(writer,w);
strcpy(public_name,pub);
price=p;
number=num;
No=no;
}
void Book::set_No(int n)
{
No=n;
}
int Book::get_No()
{
return No;
}
void Book::borrow()
{
number--;
}
void Book::restore()
{
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;
}
int main()
{
Book b;
b.setbook("University", "he","Posts & Telecom Press",50,5,1);
b.print();
b.borrow();
b.print();
b.restore();
b.print();
b.set_No(1);
b.print();
return 0;
}