// Student.h: interface for the Student class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_STUDENT_H__64B07981_EE99_4F32_9A0F_36F25D92D7AA__INCLUDED_)
#define AFX_STUDENT_H__64B07981_EE99_4F32_9A0F_36F25D92D7AA__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include<iostream>
#include"Book.h"
//#include"admin.h"
#include"bookji.h"
#include<string>
using namespace std;
class admin;
class Student
{
private:
string student_num; //学生学号
string student_name; //学生姓名
int borrow_num;
//借书的总数
int num_pend;
//计算总共多少没还
Bookji *phead;
public:
Student();
string stu_num();
Student(string,string,int borrow_num=0,int num_pend=0);
Bookji* phead_book()
{
return phead;
}
void student_research(admin &p);
void insert1(Bookji *a);
void borrow_process(admin &p,string bookname4,int outnum4);
Book* borrow_information(admin &p,string bookname4);
void display_1f();
//friend ostream &operator <<(ostream &output,Student &c1);
virtual ~Student();
};
#endif // !defined(AFX_STUDENT_H__64B07981_EE99_4F32_9A0F_36F25D92D7AA__INCLUDED_)
//////////////////////////////
////////////////////////////////
// Student.cpp: implementation of the Student class.
//
//////////////////////////////////////////////////////////////////////
#include "Student.h"
#include"Book.h"
#include"admin.h"
#include"bookji.h"
#include "ctime"
#include<iostream>
#include<string>
using namespace std;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
Student::Student(string student_num,string student_name,int borrow_num,int num_pend)
{
this->student_num=student_num;
this->student_name=student_name;
this->borrow_num=borrow_num;
this->num_pend=num_pend;
phead=new Bookji();
phead
}
string Student::stu_num()
{
return student_num;
}
void Student::student_research(admin &p)
{
cout<<"what do you need:";
string bookname3;
cin>>bookname3;
p.Research(bookname3);
}
void Student::insert1(Bookji *a) //学生插入所借入的书本
{
Bookji *p=this->phead->pnext;
this->phead->pnext=a;
a->pnext=p;
phead->pnext->display_1f();
}
void Student::borrow_process(admin &p,string namebook4,int outnum4)//借书过程及记录
{
Book *q=p.head_book();
Bookji A;
A.namebook1=namebook4;
A.num1=outnum4;
A.outnum1=outnum4;
time_t rawtime;
struct tm * timeinfo;
time (&rawtime );
timeinfo = localtime ( &rawtime );
A.borrow_time=asctime (timeinfo);
this->insert1(&A);
q=q->next;
while(q->namebook!=namebook4)
q=q->next;
int temp;
temp=q->outnum;
q->outnum=(temp+outnum4);
temp=q->num;
q->num=temp-outnum4;
borrow_num=borrow_num+outnum4;
num_pend=num_pend+outnum4;
this->display_1f();
}
void Student::display_1f()
{
cout<<student_num<<" "<<student_name<<" ";
Bookji *p=phead;
while(p->pnext!=NULL)
{
p->pnext->display_1f();
p=p->pnext;
}
cout<<borrow_num<<" "<<num_pend<<endl;
}
/*ostream &operator <<(ostream &output,Student &c1)
{
output<<c1.student_num<<" ";
output<<c1.student_name<<" ";
output<<c1.borrow_time<<" ";
output<<c1.borrow_num<<" ";
output<<c1.num_pend<<" ";
return output;
}*/
Book* Student::borrow_information(admin &p,string namebook4)
{
Book*q=p.head_book();
while(q->next->namebook!=namebook4)
q=q->next;
return q->next;
}
Student::~Student()
{
}