| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1495 人关注过本帖
标题:写的一个图书管理系统 希望大家来改进下
只看楼主 加入收藏
zaq2008
Rank: 2
等 级:论坛游民
帖 子:23
专家分:13
注 册:2010-8-14
收藏
 问题点数:0 回复次数:14 
写的一个图书管理系统 希望大家来改进下
程序代码:
#ifndef BOOK_H
#define BOOK_H
#include <string>
#include <iostream>
#include <vector>
using std::ostream;
using std::istream;
using std::string;

class Book{                 //书类
    public:
    friend void  output_book(std::vector<Book>::iterator &a);
    friend ostream& operator<<(ostream& os,std::vector<Book>::iterator &a);
    Book():Inventory(0),Intended(0){};
    Book(string title,string category,string press,string responsible,string isbn,string seriesname,string keywords,int inventory,int intended=0);
    bool Compare_title(const string& isbn)const;
    bool Compare_isbn(const string& title)const;
    friend istream& operator>>(istream& os,Book &a);
    void edit_Title(string title);
    void edit_Category(string category);
    void edit_Press(string press);
    void edit_Responsible(string responsible);
    void edit_ISBN(string isbn);
    void edit_SeriesName(string seriesname);
    void edit_Keywords(string keyword);
    void edit_Inventory(int inventory);
    string get_Title();
    string get_Category();
    string get_Press();
    string get_Responsible();
    string get_ISBN();
    string get_SeriesName();
    string get_Keywords();
    int get_Inventory();
    int get_Intended();
    void add_Intended();
    void less_Intended();
    void add_Inventory();
    void less_Inventory();
    private:
    string Title;           //题名
    string Category;        //分类
    string Press;           //出版社
    string Responsible;     //责任者
    string ISBN;            //ISBN
    string SeriesName;      //丛书名
    string Keywords;        //主题词
    int Inventory;          //库存
    int Intended;           //预定量
    };
#endif
代码写的有点凌乱  大家将就着看吧。。
希望大家对这个程序提些意见,好下次改进。

[ 本帖最后由 zaq2008 于 2011-1-18 23:57 编辑 ]
搜索更多相关主题的帖子: color 
2011-01-18 23:52
zaq2008
Rank: 2
等 级:论坛游民
帖 子:23
专家分:13
注 册:2010-8-14
收藏
得分:0 
程序代码:
#include "book.h"
#include <vector>
#include <iostream>
#include <windows.h>
#include <string>
using std::cout;
using std::endl;
using std::string;
Book::Book(string title,string category,string press,string responsible,string isbn,string seriesname,string keywords,int inventory,int intended):
Title(title),Category(category),Press(press),Responsible(responsible),ISBN(isbn),SeriesName(seriesname),Keywords(keywords),Inventory(inventory),Intended(intended){}

bool Book::Compare_isbn(const string& isbn) const {
    if(isbn==ISBN) return true;
    return false;
    }
bool Book::Compare_title(const string& title)const{
    if(title==Title) return true;
    return false;
    }

std::vector<Book>::iterator book_find_by_title(std::vector<Book> &x,string y){
    for(std::vector<Book>::iterator iter=x.begin();iter!=x.end();++iter)
    if(iter->Compare_title(y)) return iter;
    return x.end();
    }
   
std::vector<Book>::iterator book_find_by_isbn(std::vector<Book> &x,string y){
    for(std::vector<Book>::iterator iter=x.begin();iter!=x.end();++iter)
    if(iter->Compare_isbn(y)) return iter;
    return x.end();
    }


   
void  output_book(std::vector<Book>::iterator &a){
        system("cls");
    cout<< "\n\n\n\t\t书  名:"<<a->Title<<"\n"
    <<"\t\t分  类:"<<a->Category<<"\n"
    <<"\t\t出版社:"<<a->Press<<"\n"
    <<"\t\t责任者:"<<a->Responsible<<"\n"
    <<"\t\t ISBN :"<<a->ISBN<<"\n"
    <<"\t\t丛书名:"<<a->SeriesName<<"\n"
    <<"\t\t主题词:"<<a->Keywords<<"\n"
    <<"\t\t库  存:"<<a->Inventory<<endl;
    }

istream& operator>>(istream& os,Book &a){
    os>>a.Title>>a.Category>>a.Press>>a.Responsible>>a.ISBN>>a.SeriesName>>a.Keywords>>a.Inventory>>a.Intended;
    return os;
    }

ostream& operator<<(ostream& os,std::vector<Book>::iterator &a){
    os<<a->Title<<" "<<a->Category<<" "<<a->Press<<" "<<a->Responsible<<" "<<a->ISBN<<" "<<a->SeriesName<<" "<<a->Keywords<<" "<<a->Inventory<<" "<<a->Intended;
    return os;
    }
   
void Book::edit_Title(string title){
        Title=title;
    }
       
void Book::edit_Category(string category){
    Category=category;
    }
   
void Book::edit_Press(string press){
    Press=press;
    }
   
void Book::edit_Responsible(string responsible){
    Responsible=responsible;
    }
   
void Book::edit_ISBN(string isbn){
    ISBN=isbn;
    }
   
void Book::edit_SeriesName(string seriesname){
    SeriesName=seriesname;
    }
   
void Book::edit_Keywords(string keyword){
    Keywords=keyword;
    }

void Book::edit_Inventory(int inventory){
    Inventory=inventory;
    }

string Book::get_Title(){
    return Title;
    }
       
string Book::get_Category(){
    return Category;
    }
   
string Book::get_Press(){
    return Press;
    }
   
string Book::get_Responsible(){
    return Responsible;
    }
   
string Book::get_ISBN(){
    return ISBN;
    }
   
string Book::get_SeriesName(){
    return SeriesName;
    }
   
string Book::get_Keywords(){
    return Keywords;
    }

int Book::get_Inventory(){
    return Inventory;
    }
   
int Book::get_Intended(){
    return Intended;
    }

void Book::add_Intended(){
    ++Intended;
    }

void Book::less_Intended(){
    --Intended;
    }

void Book::add_Inventory(){
    ++Inventory;
    }

void Book::less_Inventory(){
    --Inventory;
    }
2011-01-18 23:53
zaq2008
Rank: 2
等 级:论坛游民
帖 子:23
专家分:13
注 册:2010-8-14
收藏
得分:0 
程序代码:
#ifndef USER_H
#define USER_H
#include <map>
#include <string>
#include <windows.h>
#include <iostream>
#include <vector>
using std::string;
using std::map;
using std::ostream;
using std::istream;
struct Date{
    Date(){}
    Date(int year,int months,int day):Year(year),Months(months),Day(day){}
    int Year;
    int Months;
    int Day;
};
   
class User{
    public:
    User(){}
    User(string name,string sex,string stuid,string password):Name(name),Sex(sex),StuID(stuid),Password(password){}
    string getname();
    void push_book(const string&,SYSTEMTIME);
    void booking_book(const string&);
    void back_book(const string&);
    void output();
    void output_booking();
    bool userok(string name,string password);
    friend ostream& operator<<(ostream& os,std::vector<User>::iterator &a);
    friend istream& operator>>(istream&,User&);
    private:
    string Name;
    string Sex;
    string StuID;
    string Password;
};
#endif
2011-01-18 23:53
zaq2008
Rank: 2
等 级:论坛游民
帖 子:23
专家分:13
注 册:2010-8-14
收藏
得分:0 
程序代码:
#include "user.h"
#include "book.h"
#include <cstdlib>
#include <windows.h>
#include <map>
#include <iostream>
#include <vector>
using std::cout;
using std::endl;
using std::ostream;
using std::istream;
extern std::vector<Book> books;
extern std::multimap< std::string,std::pair<string,Date> > Books;
extern std::multimap<std::string,std::string> Booking;

std::vector<Book>::iterator book_find_by_title(std::vector<Book> &x,string y);
void User::push_book(const string& name,SYSTEMTIME time){
    std::vector<Book>::iterator iter=book_find_by_title(books,name);
    if(iter->get_Intended()){
    cout<<"\t\t借书失败!已经没有库存。"<<endl;
    return ;
        }
    Books.insert(std::multimap< std::string,std::pair<std::string,Date> >::value_type(Name,std::pair<std::string,Date>(name,Date(time.wYear,time.wMonth,time.wDay))));
    cout<<"\t\t借书成功!"<<endl;
    std::vector<Book>::iterator p;
    p=book_find_by_title(books,name);
    p->less_Inventory();
    system("PAUSE");
    }
   
void User::booking_book(const string& name){
    Booking.insert(std::multimap<std::string,std::string>::value_type(Name,name));
    cout<<"\t\t预定图书成功!"<<endl;
    std::vector<Book>::iterator p;
    p=book_find_by_title(books,name);
    p->add_Intended();
    system("PAUSE");
    }
void User::back_book(const string& name){
    std::multimap< std::string,std::pair<std::string,Date> >::iterator iter;
    for(iter=Books.begin();iter!=Books.end();++iter)
    if(iter->second.first==name) break;
    if(iter==Books.end()) {
        cout<<"\t\t您没有借此书。 谢谢合作!"<<endl;
        system("PAUSE");
        return;}
    Books.erase(iter->first);
    cout<<"\t\t还书成功!"<<endl;
    std::vector<Book>::iterator p;
    p=book_find_by_title(books,name);
    p->add_Inventory();
    system("PAUSE");
    }
   
string User::getname(){
    return Name;
    }
   
bool User::userok(string name,string password){
    if((Name==name)&&(Password==password)) return true;
    return false;
    }   
   
istream& operator>>(istream& os,User &a){
    os>>a.Name>>a.Sex>>a.StuID>>a.Password;
    return os;
    }
    

ostream& operator<<(ostream &os,const Date &date){
    os << date.Year <<" " <<date.Months<<" "<<date.Day;
    return os;
    }


ostream& operator<<(ostream& os,std::vector<User>::iterator &a){
    os<<a->Name<<" "<<a->Sex<<" "<<a->StuID<<" "<<a->Password;
    return os;
    }
   
void User::output(){
    cout<<"\n\n\t\t书名\t\t借阅时间"<<endl ;
    for(std::multimap< std::string,std::pair<std::string,Date> >::iterator iter=Books.begin();iter!=Books.end();++iter)
    if((iter->first)==Name)
    cout<<"\t\t"<< iter->second.first <<"\t\t"<<iter->second.second.Year<<"/"<<iter->second.second.Months<<"/"<<iter->second.second.Day<<endl;   
    }

void User::output_booking(){
    cout<<"\n\n\t\t书名"<<endl ;
    for(std::multimap<std::string,std::string>::iterator iter=Booking.begin();iter!=Booking.end();++iter)
    if((iter->first)==Name)
    cout<<"\t\t"<< iter->second << endl;   
    }
   
bool ibooks(istream& os,std::multimap< std::string,std::pair<std::string,Date> > &a){
    std::string Name;
    std::string name;
    int year;
    int mon;
    int day;
    os>>Name>>name>>year>>mon>>day;
    if(os)
    a.insert(std::multimap< std::string,std::pair<std::string,Date> >::value_type(Name,std::pair<std::string,Date>(name,Date(year,mon,day))));
    return os;
    }

bool booking(istream& os,std::multimap<std::string,std::string> &a){ 
    std::string Name;
    std::string name;
    os>>Name>>name;
    if(os)
    a.insert(std::multimap< std::string,std::string>::value_type(Name,name));
    return os;
    }
2011-01-18 23:53
zaq2008
Rank: 2
等 级:论坛游民
帖 子:23
专家分:13
注 册:2010-8-14
收藏
得分:0 
程序代码:
#include <iostream>
#include <windows.h>
#include <fstream>
#include <string>
#include <vector>
#include "book.h"
#include "user.h"
using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::ofstream;
extern std::vector<Book> books;
extern std::vector<User> users;
extern std::multimap< std::string,std::pair<string,Date> > Books;
extern std::multimap<std::string,std::string> Booking;
std::vector<Book>::iterator book_find_by_title(std::vector<Book> &x,string y);
std::vector<Book>::iterator book_find_by_isbn(std::vector<Book> &x,string y);
ostream& operator<<(ostream &os,const Date &date);
void  output_book(Book &a);
void book_find(SYSTEMTIME);
void book_booking(SYSTEMTIME);
void aboutbooks(SYSTEMTIME);
void bookname(SYSTEMTIME time);
void bookisbn(SYSTEMTIME time);
int user_login(SYSTEMTIME time);
void to_book_booking(SYSTEMTIME time);
void to_book_back(SYSTEMTIME time);
void to_book_books(SYSTEMTIME time);
void select_books(SYSTEMTIME time);
void update_book(std::vector<Book>::iterator b,SYSTEMTIME time);
void to_edit_Title(std::vector<Book>::iterator b);
void to_edit_Category(std::vector<Book>::iterator b);
void to_edit_Press(std::vector<Book>::iterator b);
void to_edit_Responsible(std::vector<Book>::iterator b);  
void to_edit_ISBN(std::vector<Book>::iterator b);
void to_edit_SeriesName(std::vector<Book>::iterator b);
void to_edit_Keywords(std::vector<Book>::iterator b);
void to_edit_Inventory(std::vector<Book>::iterator b);
void booking_deal_with(SYSTEMTIME time);
void be_ofstream();
void nouser();
std::vector<User>::iterator p;

 

void gotoxy(int x,int y){               //控制光标
    COORD c;  
    c.X   =   x   -   1;  
    c.Y   =   y   -   1;  
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),c);  
} 

bool detection(string Name,string Password){
    for(std::vector<User>::iterator iter=users.begin();iter!=users.end();++iter)
    if(iter->userok(Name,Password)) {
        p=iter;
        return true;
        }
    return false;
    }
   
void addbook(){
    system("cls");
    cout<<"\n\n\n\t\t书  名:\n"
    <<"\t\t分  类:\n"
    <<"\t\t出版社:\n"
    <<"\t\t责任者:\n"
    <<"\t\t ISBN :\n"
    <<"\t\t丛书名:\n"
    <<"\t\t主题词:\n"
    <<"\t\t库  存:"<<endl;
    string title;
    string category;
    string press;
    string responsible;
    string isbn;
    string seriesname;
    string keywords;
    int inventory;
    gotoxy(25,4);
    cin>>title;
    gotoxy(25,5);
    cin>>category;
    gotoxy(25,6);
    cin>>press;
    gotoxy(25,7);
    cin>>responsible;
    gotoxy(25,8);
    cin>>isbn;
    gotoxy(25,9);
    cin>>seriesname;
    gotoxy(25,10);
    cin>>keywords;
    gotoxy(25,11);
    cin>>inventory;
    books.push_back(Book(title,category,press,responsible,isbn,seriesname,keywords,inventory));
    gotoxy(20,12);
    cout<<" 录入成功!"<<endl;
        system("PAUSE");
}

void adduser(){
    system("cls");
    cout<<"\n\n\n\t\t姓名:\n"
    <<"\t\t性别:\n"
    <<"\t\t学号:\n"
    << "\t\t密码:"<<endl;
    string name,sex,stuid,password;
    gotoxy(25,4);
    cin>>name;
    gotoxy(25,5);
    cin>>sex;
    gotoxy(25,6);
    cin>>stuid;
    gotoxy(25,7);
    cin>>password;
    users.push_back(User(name,sex,stuid,password));
    gotoxy(20,8);
    cout<<" 注册成功! 请返回重新登录! "<<endl;
    system("PAUSE");
    }


void menu(SYSTEMTIME time){
    ostream& operator<<(ostream& os, std::multimap< std::string,std::pair<string,Date> >::iterator iter);
    while(1){
    system("cls");
    void user(SYSTEMTIME time);
    void admin(SYSTEMTIME time);
    cout<<"\n\n"
    <<"\t\t当前时间: "<<time.wYear<<"/"<<time.wMonth<<"/"<<time.wDay<<" "
    <<time.wHour<<":"<<time.wMinute<<":"<<time.wSecond<<endl
    <<"\t\t*****************************************************\n"
    <<"\t\t*****************************************************\n"
    <<"\t\t*************                           *************\n"
    <<"\t\t*************   欢迎使用图书管理系统    *************\n"
    <<"\t\t*************                           *************\n"
    <<"\t\t*****************************************************\n"
    <<"\t\t*****************************************************\n"
    <<"\t\t*************                           *************\n"
    <<"\t\t*************        1.用户模式         *************\n"
    <<"\t\t*************        2.管理员模式       *************\n"
    <<"\t\t*************                           *************\n"
    <<"\t\t*****************************************************\n"
    <<"\t\t*****************************************************\n"
    <<"\t\t*************    输入其他任何数退出     *************\n"
    <<"\t\t*****************************************************\n"
    <<"\t\t*****************************************************\n"
    <<"\t\t*************    请选择:               *************\n"
    <<"\t\t*****************************************************\n"
    <<"\t\t*****************************************************"<<endl;
//    for(std::multimap< std::string,std::pair<string,Date> >::iterator iter=Books.begin();iter!=Books.end();++iter){
//    cout<<iter->first<<" "<<iter->second.first<<" "<<iter->second.second.Year<<" "<<iter->second.second.Months<<" "<<iter->second.second.Day<<endl;
//}
    gotoxy(45,20);
    int a;
    cin>>a;
    switch(a){
        case 1:if(int x=user_login(time)!=0){if(x==1)user(time);else break;}else {nouser();adduser();}break;
        case 2:admin(time);
        default:be_ofstream();exit(0);
        }
    }
}
   
void user(SYSTEMTIME time){
    while(1){
    system("cls");
    cout<<"\n\t\t"<<p->getname()<<",欢迎使用本系统!\n"
    <<"\t\t当前时间: "<<time.wYear<<"/"<<time.wMonth<<"/"<<time.wDay<<" "
    <<time.wHour<<":"<<time.wMinute<<":"<<time.wSecond<<endl
    <<"\t\t**************************************************\n"
    <<"\t\t**************************************************\n"
    <<"\t\t***********                            ***********\n"
    <<"\t\t***********       1.图书库存查询       ***********\n"
    <<"\t\t***********       2.已借图书查询       ***********\n"
    <<"\t\t***********       3.图 书 预 定        ***********\n"
    <<"\t\t***********       4.图 书 借 还        ***********\n"
    <<"\t\t***********       5.   退  出          ***********\n"
    <<"\t\t***********                            ***********\n"
    <<"\t\t**************************************************\n"
    <<"\t\t**************************************************\n"
    <<"\t\t***********       请选择:             ***********\n"
    <<"\t\t**************************************************\n"
    <<"\t\t**************************************************"<<endl;
    gotoxy(45,15);
    int a;
    cin>>a;
    switch(a){
        case 1:system("cls");book_find(time);break;
        case 2:system("cls");p->output();system("PAUSE");break;
        case 3:system("cls");book_booking(time);break;
        case 4:system("cls");aboutbooks(time);break;
        case 5:be_ofstream();exit(0);
        default:gotoxy(45,18);cout<<"\n\n\t\t无效输入!请重新选择!"<<endl;system("PAUSE");
        }
    }
}
   
void admin(SYSTEMTIME time){
    while(1){
    system("cls");
    cout<<"\n\n"
    <<"\t\t当前时间: "<<time.wYear<<"/"<<time.wMonth<<"/"<<time.wDay<<" "
    <<time.wHour<<":"<<time.wMinute<<":"<<time.wSecond<<endl
    <<"\t\t**************************************************\n"
    <<"\t\t**************************************************\n"
    <<"\t\t***********                            ***********\n"
    <<"\t\t***********       1.图书库存查询       ***********\n"
    <<"\t\t***********       2.图 书 录 入        ***********\n"
    <<"\t\t***********       3.图 书 更 新        ***********\n"
    <<"\t\t***********       4.图书预定处理       ***********\n"
    <<"\t\t***********       5.   退  出          ***********\n"
    <<"\t\t***********                            ***********\n"
    <<"\t\t**************************************************\n"
    <<"\t\t**************************************************\n"
    <<"\t\t***********       请选择:             ***********\n"
    <<"\t\t**************************************************\n"
    <<"\t\t**************************************************"<<endl;
    gotoxy(45,15);
    int a;
    cin>>a;
    switch(a){
        case 1:system("cls");book_find(time);break;
        case 2:system("cls");addbook();break;
        case 3:system("cls");select_books(time);break;
        case 4:system("cls");booking_deal_with(time);break;
        case 5:be_ofstream();exit(0);
        default:gotoxy(45,18);cout<<"\n\n\t\t无效输入!请重新选择!"<<endl;system("PAUSE");
        }
    }
}

void book_find(SYSTEMTIME time){
    while(1){
    system("cls");
    cout<<"\n\n"
    <<"\t\t当前时间: "<<time.wYear<<"/"<<time.wMonth<<"/"<<time.wDay<<" "
    <<time.wHour<<":"<<time.wMinute<<":"<<time.wSecond<<endl
    <<"\t\t**************************************************\n"
    <<"\t\t**************************************************\n"
    <<"\t\t***********                            ***********\n"
    <<"\t\t***********   本系统提供两种查询方式   ***********\n"
    <<"\t\t***********                            ***********\n"
    <<"\t\t***********       1.通过书名查询       ***********\n"
    <<"\t\t***********       2.通过ISBN查询       ***********\n"
    <<"\t\t***********       3.   返  回          ***********\n"
    <<"\t\t***********                            ***********\n"
    <<"\t\t**************************************************\n"
    <<"\t\t**************************************************\n"
    <<"\t\t***********       请选择:             ***********\n"
    <<"\t\t**************************************************\n"
    <<"\t\t**************************************************"<<endl;
    gotoxy(45,15);
    int a;
    cin>>a;
    switch(a){
        case 1: bookname(time);break;
        case 2: bookisbn(time);break;
        case 3: return;
        default:gotoxy(45,18);cout<<"\n\n\t\t无效输入!请重新选择!"<<endl;system("PAUSE");
        }
    }
}
   
void book_booking(SYSTEMTIME time){
    while(1){
    system("cls");
    cout<<"\n\n"
    <<"\t\t当前时间: "<<time.wYear<<"/"<<time.wMonth<<"/"<<time.wDay<<" "
    <<time.wHour<<":"<<time.wMinute<<":"<<time.wSecond<<endl
    <<"\t\t**************************************************\n"
    <<"\t\t**************************************************\n"
    <<"\t\t***********                            ***********\n"
    <<"\t\t***********      请选择需要的功能      ***********\n"
    <<"\t\t***********                            ***********\n"
    <<"\t\t***********       1.查询已预定图书     ***********\n"
    <<"\t\t***********       2.预 定 新 书        ***********\n"
    <<"\t\t***********       3.   返  回          ***********\n"
    <<"\t\t***********                            ***********\n"
    <<"\t\t**************************************************\n"
    <<"\t\t**************************************************\n"
    <<"\t\t***********       请选择:             ***********\n"
    <<"\t\t**************************************************\n"
    <<"\t\t**************************************************"<<endl;
    gotoxy(45,15);
    int a;
    cin>>a;
    switch(a){
        case 1: system("cls");p->output_booking();system("PAUSE");break;
        case 2: system("cls");to_book_booking(time);break;
        case 3: return;
        default:gotoxy(45,18);cout<<"无效输入!请重新选择!"<<endl;system("PAUSE");
        }
    }
}
   
void aboutbooks(SYSTEMTIME time){
    while(1){
    system("cls");
    cout<<"\n\n"
    <<"\t\t当前时间: "<<time.wYear<<"/"<<time.wMonth<<"/"<<time.wDay<<" "
    <<time.wHour<<":"<<time.wMinute<<":"<<time.wSecond<<endl
    <<"\t\t**************************************************\n"
    <<"\t\t**************************************************\n"
    <<"\t\t***********                            ***********\n"
    <<"\t\t***********      请选择需要的功能      ***********\n"
    <<"\t\t***********                            ***********\n"
    <<"\t\t***********       1.借 阅 图 书        ***********\n"
    <<"\t\t***********       2.归 还 图 书        ***********\n"
    <<"\t\t***********       3.   返 回           ***********\n"
    <<"\t\t***********                            ***********\n"
    <<"\t\t**************************************************\n"
    <<"\t\t**************************************************\n"
    <<"\t\t***********       请选择:             ***********\n"
    <<"\t\t**************************************************\n"
    <<"\t\t**************************************************"<<endl;
    gotoxy(45,15);
    int a;
    cin>>a;
    switch(a){
        case 1: system("cls");to_book_books(time);break;
        case 2: system("cls");to_book_back(time);break;
        case 3: return;
        default:gotoxy(45,18);cout<<"\n\n\t\t无效输入!请重新选择!"<<endl;system("PAUSE");
        }
    }
}

void bookname(SYSTEMTIME time){
    while(1){
    system("cls");
    cout<<"\n\n"
    <<"\t\t当前时间: "<<time.wYear<<"/"<<time.wMonth<<"/"<<time.wDay<<" "
    <<time.wHour<<":"<<time.wMinute<<":"<<time.wSecond<<endl
    <<"\t\t**************************************************\n"
    <<"\t\t**************************************************\n"
    <<"\t\t***********                            ***********\n"
    <<"\t\t***********  请输入书名:              ***********\n"
    <<"\t\t***********  输入“返回”将返回        ***********\n"
    <<"\t\t**************************************************\n"
    <<"\t\t**************************************************"<<endl;
    gotoxy(42,7);
    string a;
    cin>>a;
    std::vector<Book>::iterator p;
    if(a==string("返回")) return;
    p=book_find_by_title(books,a);
    if(p!=books.end()) {output_book(p);system("PAUSE");}
    else {gotoxy(42,11);cout<<"\n\n\n\t\t书库中没有这本书!"<<endl;system("PAUSE");}
    }
}
2011-01-18 23:54
zaq2008
Rank: 2
等 级:论坛游民
帖 子:23
专家分:13
注 册:2010-8-14
收藏
得分:0 
程序代码:
void bookisbn(SYSTEMTIME time){
    while(1){
    system("cls");
    cout<<"\n\n"
    <<"\t\t当前时间: "<<time.wYear<<"/"<<time.wMonth<<"/"<<time.wDay<<" "
    <<time.wHour<<":"<<time.wMinute<<":"<<time.wSecond<<endl
    <<"\t\t**************************************************\n"
    <<"\t\t**************************************************\n"
    <<"\t\t***********                            ***********\n"
    <<"\t\t***********  请输入ISBN:              ***********\n"
    <<"\t\t***********  输入“返回”将返回        ***********\n"
    <<"\t\t**************************************************\n"
    <<"\t\t**************************************************"<<endl;
    gotoxy(42,7);
    string a;
    cin>>a;
    std::vector<Book>::iterator p;
    if(a==string("返回")) return;
    if((p=(book_find_by_isbn(books,a)))!=books.end()) {output_book(p);system("PAUSE");}
    else {gotoxy(42,11);cout<<"\n\n\n\t\t书库中没有这本书!"<<endl;system("PAUSE");}
    }
}

int user_login(SYSTEMTIME time){
    system("cls");
    cout<<"\n\n"
    <<"\t\t当前时间: "<<time.wYear<<"/"<<time.wMonth<<"/"<<time.wDay<<" "
    <<time.wHour<<":"<<time.wMinute<<":"<<time.wSecond<<endl
    <<"\t\t**************************************************\n"
    <<"\t\t**************************************************\n"
    <<"\t\t***********  请输入帐号、密码          ***********\n"
    <<"\t\t***********  姓名:                    ***********\n"
    <<"\t\t***********  密码:                    ***********\n"
    <<"\t\t***********  输入“返回”将返回        ***********\n"
    <<"\t\t**************************************************\n"
    <<"\t\t**************************************************"<<endl;
    gotoxy(42,7);
    string a,b;
    cin>>a;
    if(a==string("返回")) return 2;
    gotoxy(42,8);
    cin>>b;
    if(detection(a,b))return 1;
    gotoxy(20,12);
    cout<<"用户不存在或密码错误!"<<endl;
    return 0;
}

void nouser(){
    gotoxy(20,13);
    cout<<"添加新用户,输入\"是\" 否则请输入\"任意字符\"退出!"<<endl;
    string s;
    gotoxy(20,14);
    cout<<"请输入:" ;
    cin>>s;
    if(s==string(""))  return;
    exit(0);
    }

void to_book_booking(SYSTEMTIME time){
    while(1){
    system("cls");
    cout<<"\n\n"
    <<"\t\t当前时间: "<<time.wYear<<"/"<<time.wMonth<<"/"<<time.wDay<<" "
    <<time.wHour<<":"<<time.wMinute<<":"<<time.wSecond<<endl
    <<"\t\t**************************************************\n"
    <<"\t\t**************************************************\n"
    <<"\t\t***********                            ***********\n"
    <<"\t\t***********  请输入书名:              ***********\n"
    <<"\t\t***********  输入“返回”将返回        ***********\n"
    <<"\t\t**************************************************\n"
    <<"\t\t**************************************************"<<endl;
    gotoxy(42,7);
    string a;
    cin>>a;
    std::vector<Book>::iterator b;
    if(a==string("返回")) return;
    if((b=(book_find_by_title(books,a)))!=books.end()) {p->booking_book(a);}
    else {gotoxy(42,11);cout<<"\n\n\n\t\t书库中没有这本书!"<<endl;system("PAUSE");}
    }
}

void to_book_books(SYSTEMTIME time){
    while(1){
    system("cls");
    cout<<"\n\n"
    <<"\t\t当前时间: "<<time.wYear<<"/"<<time.wMonth<<"/"<<time.wDay<<" "
    <<time.wHour<<":"<<time.wMinute<<":"<<time.wSecond<<endl
    <<"\t\t**************************************************\n"
    <<"\t\t**************************************************\n"
    <<"\t\t***********                            ***********\n"
    <<"\t\t***********  请输入书名:              ***********\n"
    <<"\t\t***********  输入“返回”将返回        ***********\n"
    <<"\t\t**************************************************\n"
    <<"\t\t**************************************************"<<endl;
    gotoxy(42,7);
    string a;
    cin>>a;
    std::vector<Book>::iterator b;
    if(a==string("返回")) return;
    if((b=(book_find_by_title(books,a)))!=books.end()) {gotoxy(11,11);p->push_book(a,time);}
    else {gotoxy(42,11);cout<<"\n\n\n\t\t书库中没有这本书!"<<endl;system("PAUSE");}
    }
}

void to_book_back(SYSTEMTIME time){
    while(1){
    system("cls");
    cout<<"\n\n"
    <<"\t\t当前时间: "<<time.wYear<<"/"<<time.wMonth<<"/"<<time.wDay<<" "
    <<time.wHour<<":"<<time.wMinute<<":"<<time.wSecond<<endl
    <<"\t\t**************************************************\n"
    <<"\t\t**************************************************\n"
    <<"\t\t***********                            ***********\n"
    <<"\t\t***********  请输入书名:              ***********\n"
    <<"\t\t***********  输入“返回”将返回        ***********\n"
    <<"\t\t**************************************************\n"
    <<"\t\t**************************************************"<<endl;
    gotoxy(42,7);
    string a;
    cin>>a;
    if(a==string("返回")) return;
    gotoxy(11,11);
    p->back_book(a);
    }
}

void select_books(SYSTEMTIME time){
    while(1){
    system("cls");
    cout<<"\n\n"
    <<"\t\t当前时间: "<<time.wYear<<"/"<<time.wMonth<<"/"<<time.wDay<<" "
    <<time.wHour<<":"<<time.wMinute<<":"<<time.wSecond<<endl
    <<"\t\t**************************************************\n"
    <<"\t\t**************************************************\n"
    <<"\t\t***********                            ***********\n"
    <<"\t\t***********  请输入书名:              ***********\n"
    <<"\t\t***********  输入“返回”将返回        ***********\n"
    <<"\t\t**************************************************\n"
    <<"\t\t**************************************************"<<endl;
    gotoxy(42,7);
    string a;
    cin>>a;
    std::vector<Book>::iterator b;
    if(a==string("返回")) return;
    if((b=(book_find_by_title(books,a)))!=books.end()) {update_book(b,time);}
    else {gotoxy(42,11);cout<<"\n\n\n\t\t书库中没有这本书!"<<endl;system("PAUSE");}
    }
}

void update_book(std::vector<Book>::iterator b,SYSTEMTIME time){
    while(1){
    system("cls");
    cout<<"\n\n"
    <<"\t\t当前时间: "<<time.wYear<<"/"<<time.wMonth<<"/"<<time.wDay<<" "
    <<time.wHour<<":"<<time.wMinute<<":"<<time.wSecond<<endl
    <<"\t\t**************************************************\n"
    <<"\t\t**************************************************\n"
    <<"\t\t***********     请选择要更新的部分     ***********\n"
    <<"\t\t***********     1.题  名               ***********\n"
    <<"\t\t***********     2.分  类               ***********\n"
    <<"\t\t***********     3.出版社               ***********\n"
    <<"\t\t***********     4.责任者               ***********\n"
    <<"\t\t***********     5. ISBN                ***********\n"
    <<"\t\t***********     6.丛书名               ***********\n"
    <<"\t\t***********     7.主题词               ***********\n"
    <<"\t\t***********     8.库  存               ***********\n"
    <<"\t\t***********     9.返  回               ***********\n"
    <<"\t\t**************************************************\n"
    <<"\t\t**************************************************\n"
    <<"\t\t***********       请选择:             ***********\n"
    <<"\t\t**************************************************\n"
    <<"\t\t**************************************************"<<endl;
    gotoxy(45,18);
    int a;
    cin>>a;
    switch(a){
        case 1: system("cls");to_edit_Title(b);break;
        case 2: system("cls");to_edit_Category(b);break;
        case 3: system("cls");to_edit_Press(b);break;
        case 4: system("cls");to_edit_Responsible(b);break;
        case 5: system("cls");to_edit_ISBN(b);break;
        case 6: system("cls");to_edit_SeriesName(b);break;
        case 7: system("cls");to_edit_Keywords(b);break;
        case 8: system("cls");to_edit_Inventory(b);break;
        case 9: return;
        default:gotoxy(45,21);cout<<"\n\n\t\t无效输入!请重新选择!"<<endl;system("PAUSE");
        }
    }
}

void to_edit_Title(std::vector<Book>::iterator b){
    system("cls");
    cout<<"\n\n\n\t\t题名:"<<b->get_Title()<<"  修改为:";
    string Title;
    cin>>Title;
    b->edit_Title(Title);
    }
   
void to_edit_Category(std::vector<Book>::iterator b){
    system("cls");
    cout<<"\n\n\n\t\t分类:"<<b->get_Category()<<"  修改为:";
    string Category;
    cin>>Category;
    b->edit_Category(Category);
    }
void to_edit_Press(std::vector<Book>::iterator b){
    system("cls");
    cout<<"\n\n\n\t\t出版社:"<<b->get_Press()<<"  修改为:";
    string Press;
    cin>>Press;
    b->edit_Press(Press);
    }

void to_edit_Responsible(std::vector<Book>::iterator b){
    system("cls");
    cout<<"\n\n\n\t\t责任者:"<<b->get_Responsible()<<"  修改为:";
    string Responsible;
    cin>>Responsible;
    b->edit_Responsible(Responsible);
    }

void to_edit_ISBN(std::vector<Book>::iterator b){
    system("cls");
    cout<<"\n\n\n\t\tISBN:"<<b->get_ISBN()<<"  修改为:";
    string ISBN;
    cin>>ISBN;
    b->edit_ISBN(ISBN);
    }
   
void to_edit_SeriesName(std::vector<Book>::iterator b){
    system("cls");
    cout<<"\n\n\n\t\t丛书名:"<<b->get_SeriesName()<<"  修改为:";
    string SeriesName;
    cin>>SeriesName;
    b->edit_SeriesName(SeriesName);
    }
   
void to_edit_Keywords(std::vector<Book>::iterator b){
    system("cls");
    cout<<"\n\n\n\t\t主题词:"<<b->get_Keywords()<<"  修改为:";
    string Keywords;
    cin>>Keywords;
    b->edit_Keywords(Keywords);
    }
   
void to_edit_Inventory(std::vector<Book>::iterator b){
    system("cls");
    cout<<"\n\n\n\t\t库存:"<<b->get_Inventory()<<"  修改为:";
    int Inventory;
    cin>>Inventory;
    b->edit_Inventory(Inventory);
    }

void booking_deal_with(SYSTEMTIME time){
    while(1){
    system("cls");
    std::multimap<std::string,std::string>::iterator iter=Booking.begin();
    cout<<"\n\n"
    <<"\t\t当前时间: "<<time.wYear<<"/"<<time.wMonth<<"/"<<time.wDay<<" "
    <<time.wHour<<":"<<time.wMinute<<":"<<time.wSecond<<endl
    <<"\t\t**************************************************\n"
    <<"\t\t**************************************************\n"
    <<"\t\t***********  姓名        书名          ***********\n"
    <<"\t\t***********                            ***********\n"
    <<"\t\t***********  输入“继续”将继续        ***********\n"
    <<"\t\t***********  输入“返回”将返回        ***********\n"
    <<"\t\t**************************************************\n"
    <<"\t\t***********  请输入:                  ***********\n"
    <<"\t\t**************************************************"<<endl;
    gotoxy(30,7);
    cout<<iter->first<<"\t"<<iter->second;
    gotoxy(42,11);
    string a;
    cin>>a;
    if(a==string("返回")) return;
    ++iter;
    gotoxy(42,13);
    if(iter==Booking.end()) {
        cout<<"已经没有后续了。。"<<endl;
        system("PAUSE");
        return;
        }
    }
}

ostream& operator<<(ostream& os, std::multimap< std::string,std::pair<string,Date> >::iterator iter){
    os<<iter->first<<" "<<iter->second.first<<" "<<iter->second.second;
    return os;
    }
ostream& operator<<(ostream& os, std::multimap<std::string,std::string>::iterator iter){
    os<<iter->first<<" "<<iter->second;
    return os;
    }

ostream& operator<<(ostream& os, std::vector<Book>::iterator &iter);
//{
//    os<<iter;
//    return os;
//    }

ostream& operator<<(ostream& os, std::vector<User>::iterator &iter);
//{
//    os<<iter;
//    return os;
//    }


void be_ofstream(){                     //输出到文件
    ofstream ibookout("ibooks.dat");
    for(std::multimap< std::string,std::pair<string,Date> >::iterator iter=Books.begin();iter!=Books.end();++iter){
    ibookout<<iter<<endl;   //输出
    }
    ibookout.close();
    ofstream bookingout("booking.dat");
    for(std::multimap<std::string,std::string>::iterator iter=Booking.begin();iter!=Booking.end();++iter){
    bookingout<<iter<<endl;    //输出
    }
    bookingout.close();
    ofstream bookout("books.dat");
    for(std::vector<Book>::iterator iter=books.begin();iter!=books.end();++iter){
    bookout<<iter<<endl;    //输出
    }
    bookout.close();
    ofstream userout("user.dat");
    for(std::vector<User>::iterator iter=users.begin();iter!=users.end();++iter){
    userout<<iter<<endl;    //输出
    }
    userout.close();
}

2011-01-18 23:55
zaq2008
Rank: 2
等 级:论坛游民
帖 子:23
专家分:13
注 册:2010-8-14
收藏
得分:0 
程序代码:
#include <cstdlib>
#include <iostream>
#include <windows.h>
#include <map>
#include <vector>
#include <fstream>
#include <string>
#include "book.h"
#include "user.h"
#include "admin.h"
using std::cin;
using std::cout;
using std::endl;
using std::ifstream;
//本系统尚未对输入做异常处理,请按指定输入 否则将出错。
std::vector<Book> books;        //书库定义
std::vector<User> users;        //用户定义
//  std::vector<Admin> admins;  //管理员登录 尚未制作
std::multimap< std::string,std::pair<string,Date> > Books;      //借书情况
std::multimap<std::string,std::string> Booking;                 //预定情况
bool ibooks(istream& os,std::multimap< std::string,std::pair<std::string,Date> > &a);  //借书情况输入函数
bool booking(istream& os,std::multimap<std::string,std::string> &a);                   //预定情况输入函数
void menu();

void be_ifstream(){                                     //从文件输入书库、用户、借书情况、预定情况
    ifstream ibookin("ibooks.dat");
    while(ibooks(ibookin,Books)){
    }
    ibookin.close();
    ifstream bookingin("booking.dat");
    while(booking(bookingin,Booking)){
    }
    bookingin.close();
    ifstream bookin("books.dat");
    Book bin;
    while(bookin>>bin){
    books.push_back(bin);
    }
    bookin.close();
    ifstream userin("user.dat");
    User uin;
    while(userin>>uin){
    users.push_back(uin);
    }
    userin.close();
}

int main()
{  
    be_ifstream();
    system("color 84");                     //改变文字与悲剧颜色
    SYSTEMTIME time;                        //定义时间变量
    GetLocalTime( &time );                  //获取系统时间
    void menu(SYSTEMTIME);                  //声明界面函数
    menu(time);                             //调用界面
    return EXIT_SUCCESS;
}

2011-01-18 23:55
zaq2008
Rank: 2
等 级:论坛游民
帖 子:23
专家分:13
注 册:2010-8-14
收藏
得分:0 
程序代码:
#include "user.h"

class Admin : public User {                     //管理员类 、、暂未被使用
    Admin();
    Admin(string Name,string Sex,string StuID,string Password,bool adminitretor):User(Name,Sex,StuID,Password),Adminitretor(adminitretor){}
    bool be_admin(){
    return Adminitretor;
    }
    private:
    bool Adminitretor;
};
2011-01-18 23:55
dragon3186
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2011-1-20
收藏
得分:0 
!用没用数据库啊!界面都没有,叫人咋用呢?
2011-01-20 09:59
xishui777
Rank: 2
等 级:论坛游民
帖 子:53
专家分:94
注 册:2010-8-17
收藏
得分:0 
眼睛都看花了
2011-01-20 13:10
快速回复:写的一个图书管理系统 希望大家来改进下
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.059398 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved