Project 2-books and projects of the library-libraries
/** Copyright (c) 2014, School of Computer Science, Yantai University * All right reserved. * file name: test. cpp * Author: Zhao yun* completion time: July 15, March 15, 2014 * version: v1.0 */# include <iostream> # include <string> using namespace std; class Book {private: string name; string writer; string public_name; double price; int number; int NO; public: void setBook (string n, string w, string pu, double pr, int nu, int N ); void borrow (); void restore (); void set_No (int); int get_No (); void print () ;}; int main () {Book book; book. setBook ("miserable world", "Hugo", "Shanghai Foreign Language Education Press", 1234,); book. print (); book. borrow (); book. print (); book. restore (); book. print (); book. set_No (4321); book. print (); return 0;} void Book: setBook (string n, string w, string pu, double pr, int nu, int N) {name = n; writer = w; public_name = pu; price = pr; number = nu; NO = N;} void Book: borrow () {number --;} void Book: restore () {number ++;} void Book: set_No (int n1) {NO = n1;} int Book: get_No () {return NO;} 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 ;}
Running result: