当前位置:网站首页>Student course selection system (curriculum design of Shandong Agricultural University)
Student course selection system (curriculum design of Shandong Agricultural University)
2022-07-02 16:27:00 【20-year-old wall supporting farmer】
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cstdlib>
#include <windows.h>
const int INC=20;
using namespace std;
class Course{
// Course number 、 Course name 、 credits 、 Total class hours 、 Theoretical hours 、 Experimental hours 、 The first semester 、 Start and end weeks 、 Class capacity 、 The number of students who choose courses ( For the initial 0)
private:
string num;
string title;
float credit;
int period;
int theory_period;
int experiment_period;
string term;
string week;
int course_people;
int people;
public:
Course(string num0="BF002345",string title0="Web3D technology ",float credit0=3,
int period0=54,int theory_period0=28,int experiment_period0=26,string term0="2016-2017-1",string week0="1-14",int course_people0=9,int people0=0)
{ num=num0;title=title0;credit=credit0;period=period0;theory_period=theory_period0;experiment_period=experiment_period0;term=term0;week=week0;course_people=course_people0;people=people0;}
void setNum(string num0){num=num0;}
void setTitle(string title0){title=title0;}
void setCredit(float credit0){credit=credit0;}
void setPeriod(int period0){period=period0;}
void setTheory_period(int theory_period0){theory_period=theory_period0;}
void setExperiment_period(int experiment_period0){experiment_period=experiment_period0;}
void setTerm(string term0){term=term0;}
void setWeek(string week0){week=week0;}
void setCourse_people(int course_people0){course_people=course_people0;}
void setPeople(int people0){people=people0;}
string getNum(){return num;}
string getTitle(){return title;}
float getCredit(){return credit;}
int getPeriod(){return period;}
int getTheory_period(){return theory_period;}
int getExperiment_period(){return experiment_period;}
string getTerm(){return term;}
string getWeek(){return week;}
int getCourse_people(){return course_people;}
int getPeople(){return people;}
void dispACourse(){
cout <<num<< '\t'<<title<< '\t'<<credit<< '\t'<<period<< '\t'<<theory_period<< '\t'<<experiment_period<< '\t'<<term<< '\t'<<week<< '\t'<<course_people<< '\t'<<people<<'\n';
}
friend class InCourse;
friend class StudentSelectCourse;
};
class Student{
// Student number 、 full name 、 college 、 Professional class
private:
string num;
string name;
string college;
string classno;
public:
Student(string num0="20136954",string name0=" Tang Wu ",string college0=" School of resources and environment ",string classno0=" In the letter 13-1"){
num=num0;name=name0;college=college0; classno=classno0;}
void setNum(string num0){num=num0;}
void setName(string name0){name=name0;}
void setCollege(string college0){college=college0;}
void setClassno(string classno0){classno=classno0;}
string getNum(){return num;}
string getName(){return name;}
string getCollege(){return college;}
string getClassno(){return classno;}
void dispAStudent(){
cout <<num<< '\t'<<name<< '\t'<<college<< '\t'<<classno<< '\n';
}
friend class Instudent;
friend class StudentSelectCourse;
};
class SelectCourse{
// Student number 、 full name 、 college 、 Course number 、 Course name 、 The first semester 、 Deselect flag (0- Selected ,1- Selection )
private:
string num;
string name;
string coursenum;
string coursetitle;
string term;
int choice;
public:
SelectCourse(string num0="20132947",string name0=" Li Guihua ",string coursenum0="BF002345",
string coursetitle0="Web3D technology ",string term0="2016-2017-1",int choice0=0)
{
num=num0;name=name0;coursenum=coursenum0;coursetitle=coursetitle0;term=term0;choice=choice0;
}
void setNum(string num0){num=num0;}
void setName(string name0){name=name0;}
void setCourseNum(string coursenum0){coursenum=coursenum0;}
void setCourseTitle(string coursetitle0){coursetitle=coursetitle0;}
void setTerm(string term0){term=term0;}
void setChoice(int choice0){choice=choice0;}
string getNum(){return num;}
string getName(){return name;}
string getCourseNum(){return coursenum;}
string getCourseTitle(){return coursetitle;}
string getTerm(){return term;}
int getChoice(){return choice;}
void dispSelectCourse(){
cout <<num<< '\t'<<name<< '\t'<< '\t'<<coursenum<< '\t'<<coursetitle<< '\t'<<term<<'\t'<<choice<<'\n';
}
friend class InSelectCourse;
friend class StudentSelectCourse;
};
class InCourse{
public:
Course *course;int coursecount;
void write2Coursefile(){
string num;
string title;
float credit;
int period;
int theory_period;
int experiment_period;
string term;
string week;
int course_people;
int people;
ofstream outf( "course.txt", ios::out ) ;
// The file name written should be the same as the file name read ; When debugging, you can take different file names , To avoid overwriting the original file
if ( !outf )
{ cerr << "File could not be open." << endl ; }
outf<<" Course information \n";
for(int i=0;i<coursecount;i++)
{
outf<<course[i].getNum()<< '\t'<<course[i].getTitle()<< '\t';
outf<<course[i].getCredit()<< '\t'<<course[i].getPeriod()<< '\t';
outf<<course[i].getTheory_period()<<'\t'<<course[i].getExperiment_period()<<'\t';
outf<<course[i].getTerm()<< '\t'<<course[i].getWeek()<< '\t' ;
outf<<course[i].getCourse_people()<< '\t'<<course[i].getPeople()<< '\n' ;
}
outf.close() ;
}
int incourseFile( char * fileName, int delLine)
{
int i;
string num;
string title;
float credit;
int period;
int theory_period;
int experiment_period;
string term;
string week;
int course_people;
int people;
ifstream inf( fileName, ios::in ) ;
if ( !inf )
{ cerr << "File could not be open." << endl ; return 1; }
char s[80];
int a;
float b;
for ( i=1; i <= delLine; i++ )
inf.getline( s,80 ) ;
i=0;
while( inf>>num>>title>>credit>>period>>theory_period>>experiment_period>>term>>week>>course_people>>people ) //{ inf.getline( s, 80 ) ; cout << s << endl ; }
{
//inf,getchar();
if(title.length()>0) i++;
}
coursecount=i;
//cout<<coursecount<<endl;
inf.clear();
inf.seekg(0,ios::beg);
for ( i=1; i <= delLine; i++ )
inf.getline( s, 80 ) ;
course=new Course[coursecount+INC];
for ( i=0; i <coursecount; i++ )
{
inf>>num>>title>>credit>>period>>theory_period>>experiment_period>>term>>week>>course_people>>people;
if(title.length()>0){
if(num[0]==10) num=num.substr(1);
course[i]=Course();
course[i].setNum(num);
course[i].setTitle(title);
course[i].setCredit(credit);
course[i].setPeriod(period);
course[i].setTheory_period(theory_period);
course[i].setExperiment_period(experiment_period);
course[i].setTerm(term);
course[i].setWeek(week);
course[i].setCourse_people(course_people);
course[i].setPeople(people);
}
}
inf.close() ;
return coursecount;
}
friend class StudentSelectCourse;
int addcourse(string num,string title,float credit,int period,int theory_period,int experiment_period,string term,string week,int course_people,int people){
int i=coursecount;
course[i]=Course();
course[i].setNum(num);
course[i].setTitle(title);
course[i].setCredit(credit);
course[i].setPeriod(period);
course[i].setTheory_period(theory_period);
course[i].setExperiment_period(experiment_period);
course[i].setTerm(term);
course[i].setWeek(week);
course[i].setCourse_people(course_people);
course[i].setPeople(people);
++coursecount;
return coursecount;
}
void searchcoursebynum(string num){// Fuzzy Lookup contains num String of
bool found=false;
for(int i=0;i<coursecount;i++)
if((course[i].getNum()).find(num)!= string::npos) {
//cout<<course[i].getNum()<< course[i].getNum().find(num)<<endl;
cout<<i<<"\t";
course[i].dispACourse();
found=true;
// return i;
}
if(!found)cout<<"course num:"<<num<<" not found."<<endl;
// return -1;
}
int searchcoursebynump(string num){// Exact search equals num String of
for(int i=0;i<coursecount;i++)
if((course[i].getNum())==num) {
//cout<<course[i].getNum()<< course[i].getNum().find(num)<<endl;
cout<<i<<"\t";
course[i].dispACourse();
return i;
}
return -1;
}
void searchcoursebytitle(string title){
bool found=false;
for(int i=0;i<coursecount;i++)
if((course[i].getTitle()).find(title)!= string::npos) {
//cout<<course[i].getTitle()<< course[i].getTitle().find(title)<<endl;
cout<<i<<"\t";
course[i].dispACourse();
found=true;
//return i;
}
if(!found)cout<<"course title:"<<title<<" not found."<<endl;
//return -1;
}
int searchcoursebytitlep(string title){
for(int i=0;i<coursecount;i++)
if(course[i].getTitle()==title) {
//cout<<course[i].getTitle()<< course[i].getTitle().find(title)<<endl;
cout<<i<<"\t";
course[i].dispACourse();
return i;
}
cout<<"course title:"<<title<<" not found."<<endl;
return -1;
}
void sortcoursebynum(){
for(int i=0;i<coursecount;i++){
int k=i;
for(int j=i+1;j<coursecount;j++)
if(course[j].getNum()<course[k].getNum()) k=j;
//cout<<k<<" k&i "<<i<<" :"<<course[i].getNum()<<"---"<<course[k].getNum()<<endl;
if(k!=i){
Course t=course[i];course[i]=course[k];course[k]=t;
}
}
}
void sortcoursebytitle(){
for(int i=0;i<coursecount;i++){
int k=i;
for(int j=i+1;j<coursecount;j++)
if(course[j].getTitle()<course[k].getTitle()) k=j;
if(k!=i){
Course t=course[i];course[i]=course[k];course[k]=t;
}
}
}
void changecoursebynum(string oldnum,string newnum){
int k=searchcoursebynump(oldnum);
if(k>=0) {
course[k].setNum(newnum);
cout<<"changecoursebynum successed:"<<endl;
course[k].dispACourse();
}
else cout<<"changecourse failed. No course of num="<<oldnum<<endl;
}
void deletecoursebynum(string num){
int k=searchcoursebynump(num);
if(k>=0) {
cout<<"Course to be deleted :"<<endl;
course[k].dispACourse();
course[k]=course[coursecount-1];
cout<<"deletecoursebynum successed:"<<endl;
coursecount--;
//return coursecount;
}
else cout<<"deletecourse failed. No course of num="<<num<<endl;
}
void changecoursebytitle(string oldtitle,string newtitle){
int k=searchcoursebytitlep(oldtitle);
if(k>=0) {
course[k].setTitle(newtitle);
cout<<"changecoursebytitle successed:"<<endl;
course[k].dispACourse();
}
else cout<<"changecourse failed. No course of title="<<oldtitle<<endl;
}
void deletecoursebytitle(string title){
int k=searchcoursebytitlep(title);
if(k>=0) {
cout<<"Course to be deleted :"<<endl;
course[k].dispACourse();
course[k]=course[coursecount-1];
cout<<"deletecoursebytitle successed:"<<endl;
coursecount--;
//return bookcount;
}
else cout<<"deletecourse failed. No course of title="<<title<<endl;
}
};
class InStudent{
public:
Student *student;int studentcount;
string a[100];
void write2Studentfile(){
}
int instudentFile( char * fileName, int delLine)
{
string num,name,college,classno;
int i;
ifstream inf( fileName, ios::in ) ;
if ( !inf )
{ cerr << "File could not be open." << endl ; return 1; }
char s[80];
for ( i=1; i <= delLine; i++ )
inf.getline( s, 80 ) ;
i=0;
while( !inf.eof() ) //{ inf.getline( s, 80 ) ; cout << s << endl ; }
{
inf.getline( s, 80,'\t' ) ;//num=s;
inf.getline( s, 80,'\t' ) ;name=s;
inf.getline( s, 80,'\t' ) ;//college=s;
inf.getline( s, 80 ) ;//classno=s;
if(name.length()>0) i++;
}
studentcount=i;
//cout<<studentcount<<endl;
inf.clear();
inf.seekg(0,ios::beg);
for ( i=1; i <= delLine; i++ )
inf.getline( s, 80 ) ;
student=new Student[studentcount+INC];
for ( i=0; i <studentcount; i++ )
{
inf.getline( s, 80,'\t' ) ;num=s;
inf.getline( s, 80,'\t' ) ;name=s;
inf.getline( s, 80,'\t' ) ;college=s;
inf.getline( s, 80 ) ;classno=s;
if(name.length()>0){
if(num[0]==10)num=num.substr(1);
student[i]=Student();
student[i].setNum(num);
student[i].setName(name);
student[i].setCollege(college);
student[i].setClassno(classno);
}
}
inf.close() ;
return studentcount;
}
int addstudent(string num,string name,string college,string classno){
int i=studentcount;
student[i]=Student();
student[i].setNum(num);
student[i].setName(name);
student[i].setCollege(college);
student[i].setClassno(classno);
++studentcount;
return studentcount;
}
// Query student information through student number
void searchstudentbynum(string num){
bool found=false;
for(int i=0;i<studentcount;i++)
if((student[i].getNum()).find(num)!= string::npos) {
cout<<i<<"\t";
student[i].dispAStudent();
found=true;
//return i;
}
if(!found)cout<<"student of num: "<<num<<" not found"<<endl;
//return -1;
}
int searchstudentbynump(string num){
for(int i=0;i<studentcount;i++)
if(student[i].getNum()==num) {
cout<<i<<"\t";
student[i].dispAStudent();
return i;
}
return -1;
}
// Search for student information by name
void searchstudentbyname(string name){
bool found=false;
for(int i=0;i<studentcount;i++)
if((student[i].getName()).find(name)!= string::npos) {
//cout<<student[i].getName()<< student[i].getName().find(name)<<endl;
cout<<i<<"\t";
student[i].dispAStudent();
found=true;
//return i;
}
if(!found)cout<<"student name:"<<name<<" not found."<<endl;
//return -1;
}
int searchstudentbynamep(string name){
for(int i=0;i<studentcount;i++)
if(student[i].getName()==name) {
//cout<<student[i].getName()<< student[i].getName().find(Name)<<endl;
cout<<i<<"\t";
student[i].dispAStudent();
return i;
}
cout<<"student name:"<<name<<" not found."<<endl;
return -1;
}
// Query student information through professional classes
void searchstudentbyclassno(string classno){
bool found=false;
for(int i=0;i<studentcount;i++)
if((student[i].getClassno()).find(classno)!= string::npos) {
cout<<i<<"\t";
student[i].dispAStudent();
found=true;
//return i;
}
if(!found)cout<<"student of classno: "<<classno<<" not found"<<endl;
//return -1;
}
int searchstudentbyclassnop(string classno){
for(int i=0;i<studentcount;i++)
if(student[i].getClassno()==classno) {
cout<<i<<"\t";
student[i].dispAStudent();
return i;
}
return -1;
}
// Sort student information in ascending order by student number
void sortstudentbynum(){
for(int i=0;i<studentcount;i++){
int k=i;
for(int j=i+1;j<studentcount;j++)
if(student[j].getNum()<student[k].getNum()) k=j;
//cout<<k<<" k&i "<<i<<" :"<<student[i].getNum()<<"---"<<student[k].getNum()<<endl;
if(k!=i){
Student t=student[i];student[i]=student[k];student[k]=t;
}
}
}
// Sort student information in ascending order by College
void sortstudentbycollege(){
for(int i=0;i<studentcount;i++){
int k=i;
for(int j=i+1;j<studentcount;j++)
if(student[j].getCollege()<student[k].getCollege()) k=j;
if(k!=i){
Student t=student[i];student[i]=student[k];student[k]=t;
}
}
}
// By student number + Name modify student information
void changestudentbynumname(string oldnum,string oldname,string newnum,string newname){
int k=searchstudentbynump(oldnum);
int j=searchstudentbynamep(oldname);
if(k>=0&&j>=0) {
student[k].setNum(newnum);
student[j].setName(newname);
cout<<"changestudentbynum+name successed:"<<endl;
student[k].dispAStudent();
}
else cout<<"changestudent failed. No reader of num+name="<<oldnum<<" "<<oldname<<endl;
}
// By student number + Name delete student information
void deletestudentbynumname(string num,string name){
int k=searchstudentbynump(num);
int j=searchstudentbynamep(name);
if(k>=0&&j>=0) {
cout<<"Student to be deleted :"<<endl;
student[j].dispAStudent();
student[j]=student[studentcount-1];
cout<<"deletestudentbynumname successed:"<<endl;
studentcount--;
//return studentcount;
}
}
friend class StudentSelectCourse;
};
class InSelectCourse{
public:
SelectCourse *selectcourse;int selectcoursecount;
void write2SelectCoursefile(){
}
int inselectcourseFile( char * fileName, int delLine)
{
string num,name,coursenum,coursetitle,term;
int choice;
int i;
ifstream inf( fileName, ios::in ) ;
if ( !inf )
{ cerr << "File could not be open." << endl ; return 1; }
char s[80];
for ( i=1; i <= delLine; i++ )
inf.getline( s, 80 ) ;
i=0;
while( !inf.eof() )
{
inf.getline( s, 80,'\t') ;
inf.getline( s, 80,'\t' ) ;
inf.getline( s, 80,'\t' ) ;
inf.getline( s, 80,'\t' ) ;
inf.getline( s, 80 ) ;
inf>>choice;
if(strlen(s)>1) i++;
}
selectcoursecount=i;
//cout<<selectcoursecount<<endl;
inf.clear();
inf.seekg(0,ios::beg);
for ( i=1; i <= delLine; i++ )
inf.getline( s, 80 ) ;
selectcourse=new SelectCourse[selectcoursecount+INC];
for ( i=0; i <selectcoursecount; i++ )
{
inf.getline( s, 80,'\t' ) ;num=s;
inf.getline( s, 80,'\t' ) ;name=s;
inf.getline( s, 80,'\t' ) ;coursenum=s;
inf.getline( s, 80,'\t' ) ;coursetitle=s;
inf.getline( s, 80,'\t' ) ;term=s;
inf>>choice;
if(name.length()>0){
if(num[0]==10)num=num.substr(1);
selectcourse[i]=SelectCourse();
selectcourse[i].setNum(num);
selectcourse[i].setName(name);
selectcourse[i].setCourseNum(coursenum);
selectcourse[i].setCourseTitle(coursetitle);
selectcourse[i].setTerm(term);
selectcourse[i].setChoice(choice);
}
}
inf.close() ;
return selectcoursecount;
}
void searchbynum(string num){
bool found=false;
for(int i=0;i<selectcoursecount;i++)
if((selectcourse[i].getNum()).find(num)!= string::npos) {
//cout<<selectcourse[i].getNum()<< selectcourse[i].getNum().find(num)<<endl;
cout<<i<<"\t";
selectcourse[i].dispSelectCourse();
found=true;
//return i;
}
if(!found)cout<<"selectcourse num:"<<num<<" not found."<<endl;
//return -1;
}
int searchbynump(string num){
for(int i=0;i<selectcoursecount;i++)
if(selectcourse[i].getNum()==num) {
//cout<<selectcourse[i].getNum()<< selectcourse[i].getNum().find(num)<<endl;
cout<<i<<"\t";
selectcourse[i].dispSelectCourse();
return i;
}
cout<<"selectcourse num:"<<num<<" not found."<<endl;
return -1;
}
void searchbycoursenum(string coursenum){
bool found=false;
for(int i=0;i<selectcoursecount;i++)
if((selectcourse[i].getCourseNum()).find(coursenum)!= string::npos) {
//cout<<selectcourse[i].getCourseNum()<< selectcourse[i].getCourseNum().find(coursenum)<<endl;
cout<<i<<"\t";
selectcourse[i].dispSelectCourse();
found=true;
//return i;
}
if(!found)cout<<"selectcourse coursenum:"<<coursenum<<" not found."<<endl;
//return -1;
}
int searchbycoursenump(string coursenum){
for(int i=0;i<selectcoursecount;i++)
if(selectcourse[i].getCourseNum()==coursenum) {
//cout<<selectcourse[i].getCourseNum()<< selectcourse[i].getNum().find(coursenum)<<endl;
cout<<i<<"\t";
selectcourse[i].dispSelectCourse();
return i;
}
cout<<"selectcourse coursenum:"<<coursenum<<" not found."<<endl;
return -1;
}
void searchbyclassno(string classno){
int i,k;
InStudent b;
b.instudentFile("student.txt",1);
int j=0;
for(i=0;i<b.studentcount;i++){
if((b.student[i].getClassno()).find(classno)!= string::npos) {
b.a[j]=b.student[i].getNum();
j++;
}
}
if(j==0)
cout<<" Students in this major class have no record of course selection "<<endl;
for(int k=0;k<j;k++)
searchbynum(b.a[k]);
}
};
class StudentSelectCourse{
InCourse cr;
InStudent st;
InSelectCourse sc;
public:
void write2file(){
cr.write2Coursefile();
st.write2Studentfile();
sc.write2SelectCoursefile();
}
void init(){
cr.incourseFile( "course.txt", 1);
st.instudentFile( "student.txt", 1);
sc.inselectcourseFile( "studcourse.txt", 1);
}
void dispCourse(){
for ( int i=0; i <cr.coursecount; i++ )
{cout<<i<<":";
cr.course[i].dispACourse();}
}
void dispStudent(){
for ( int i=0; i <st.studentcount; i++ )
{cout<<i<<":";
st.student[i].dispAStudent();}
}
void dispSelectCourse(){
for ( int i=0; i <sc.selectcoursecount; i++ )
{cout <<i<<":";
sc.selectcourse[i].dispSelectCourse();}
}
void dispCount(){
cout<<cr.coursecount<<endl;
cout<<st.studentcount<<endl;
cout<<sc.selectcoursecount<<endl;
}
void addcourse(){
string num,title,term,week;
float credit;
int period,theory_period,experiment_period,course_people,people;
char num0[80],tit[80],ter[80],wee[80];
cout<<" Course number 、 Course name 、 Course nature 、 Total class hours 、 Theoretical hours 、 Experimental hours 、 The first semester 、 Start and end weeks 、 Class capacity 、 The number of students who choose courses "<<endl;
string num1="BF002357",title0=" Big data analysis ",term0="11-14",week0=" tsinghua university press ";
float credit0=2.5;
int period0=54;
int theory_period0=27;
int experiment_period0=27;
int course_people0=45;
int people0=25;
cr.addcourse(num1,title0,credit0,period0,theory_period0,experiment_period0,term0,week0,course_people0,people0);
int i=cr.coursecount-1;
cout <<i<<":";
cr.course[i].dispACourse();
}
void addstudent(){
string num,name,college,classno;
char num0[80],nam[80],coll[80],clas[80];
cout<<" Student number 、 full name 、 college 、 Professional class :"<<endl;
string num1="20151000",name0=" Wang Tao ",college0="computer",class0="network class 1";
st.addstudent(num1,name0,college0,class0);
int i=st.studentcount-1;
cout <<i<<":";
st.student[i].dispAStudent();
}
void searchcourse(){
cout<<"2. Course information query : According to the course number 、 Course name, etc ."<<endl;
char tit[80];
string num="BF002345", title="Web3D technology ";
int i,j,k,select;
while(1){
cout<<" Course information query :"<<endl;
cout<<"1. Query by course number "<<endl;
cout<<"2. Query by course name "<<endl;
cout<<"0. return"<<endl;
cin>>select;
cin.get();
switch(select){
case 1:
cout<<" Course number :";
getline(cin,num,'\n');
cr.searchcoursebynum(num);
break;
case 2:
cout<<" Course name :";
getline(cin,title,'\n');
cr.searchcoursebytitle(title);
break;
case 0:return;
}
}
}
void sortcourse(){
int select;
cout<<"3. Course information sorting : By course number 、 Course names are sorted in ascending order ."<<endl;
cout<<" Course information sorting :"<<endl;
cout<<"1. Sort by course number "<<endl;
cout<<"2. Sort by course name "<<endl;
cout<<"0. return"<<endl;
cin>>select;
switch(select){
case 1:
cout<<" Course number :";
cr.sortcoursebynum();
dispCourse();
break;
case 2:
cout<<" Course name :";
cr.sortcoursebytitle();
dispCourse();
break;
case 0:return;
}
}
void editcourse(){
string oldnum="BF002345",oldtitle="Web3D technology ",newnum="BF002357",newtitle="Linux operating system ";
int select;
cout<<"4. Modification of course information 、 Delete : By course number 、 Modify and delete the course name ."<<endl;
while(1){
cout<<" Modification of course information 、 Delete :"<<endl;
cout<<"1. Modify according to the course number "<<endl;
cout<<"2. Delete by course number "<<endl;
cout<<"3. Modify by course name "<<endl;
cout<<"4. Delete by course name "<<endl;
cout<<"0. return"<<endl;
cin>>select;
cin.get();
switch(select){
case 1:
cout<<"old Course number :";
getline(cin,oldnum,'\n');
cout<<"new Course number :";
getline(cin,newnum,'\n');
cout<<"changecoursebynum: "<<oldnum<<" to "<<newnum<<endl;
cr.changecoursebynum(oldnum,newnum);
//dispCourse();
break;
case 2:
cout<<"delete Course number :";
getline(cin,oldnum,'\n');
cout<<"delete Course number :"<<oldnum<<endl;
cr.deletecoursebynum(oldnum);
//dispcourse();
break;
case 3:
cout<<"old Course name :";
getline(cin,oldtitle,'\n');
cout<<"new Course name :";
getline(cin,newtitle,'\n');
cout<<"changecoursebytitle: "<<oldtitle<<" to "<<newtitle<<endl;
cr.changecoursebytitle(oldtitle,newtitle);
//dispCourse();
break;
case 4:
cout<<"delete Course name :";
getline(cin,oldtitle,'\n');
cout<<"deletecoursebytitle: "<<oldtitle<<endl;
cr.deletecoursebytitle(oldtitle);
//dispCourse();
break;
case 0:return;
}
}
}
void searchstudent(){
cout<<"6. Student information inquiry : By student number 、 full name 、 Professional classes, etc ."<<endl;
char tit[80];
string num="20136954",name=" Tang Wu ",classno=" In the letter 13-1";
int i,j,k,select;
while(1){
cout<<" Student information inquiry :"<<endl;
cout<<"1. By student number "<<endl;
cout<<"2. Search by name "<<endl;
cout<<"3. Query by professional class "<<endl;
cout<<"0. return"<<endl;
cin>>select;
cin.get();
switch(select){
case 1:
cout<<" Student number :";
getline(cin,num,'\n');
st.searchstudentbynum(num);
break;
case 2:
cout<<" full name :";
getline(cin,name,'\n');
st.searchstudentbyname(name);
break;
case 3:
cout<<" Professional class :";
getline(cin,classno,'\n');
st.searchstudentbyclassno(classno);break;
case 0:return;
}
}
}
void sortstudent(){
int select;
cout<<"7. Student information ranking : According to the student id 、 Colleges, etc. are sorted in ascending order ."<<endl;
cout<<" Reader information sorting :"<<endl;
cout<<"1. Sort by student number "<<endl;
cout<<"2. Sort by College "<<endl;
cout<<"0. return"<<endl;
cin>>select;
switch(select){
case 1:
cout<<" Student number :";
st.sortstudentbynum();
dispStudent();
break;
case 2:
cout<<" college :";
st.sortstudentbycollege();
dispStudent();
break;
case 0:return;
}
}
void editstudent(){
string oldnum="2015000000",newnum="20076954",oldname="Noname",newname=" Tang Wu ";
int select;
cout<<"8. Modification of student information 、 Delete : According to the student id + Name to modify and delete reader information ."<<endl;
while(1){
cout<<" Modification of student information 、 Delete :"<<endl;
cout<<"1. According to the student id + Name change "<<endl;
cout<<"2. According to the student id + Name delete "<<endl;
cout<<"0. return"<<endl;
cin>>select;
cin.get();
switch(select){
case 1:
cout<<"old Student number + full name :";
getline(cin,oldnum,'\n');
getline(cin,oldname,'\n');
cout<<"new Student number + full name :";
getline(cin,newnum,'\n');
getline(cin,newname,'\n');
cout<<"changestudentbynumname: "<<oldnum<<" "<<oldname<<" to "<<newnum<<" "<<newname<<endl;
st.changestudentbynumname(oldnum,oldname,newnum,newname);
//dispStudent();
break;
case 2:
cout<<"delete Student number + full name :";
getline(cin,oldnum,'\n');
getline(cin,oldname,'\n');
cout<<"delete Student number + full name :"<<oldnum<<" "<<oldname<<endl;
st.deletestudentbynumname(oldnum,oldname);
//dispStudent();
break;
case 0:return;
}
}
}
void studentselectacourse(){
cout<<"9. Students' course selection : Enter the student id + Course number , If the course capacity in the course information table of the course is greater than the number of selected courses , You can choose courses ."<<endl;
string stnum="20132947",coursenum="BF002345",stname,coursetitle,term;
int choice;
int select,stpos,coursepos;
while(1){
cout<<" Students' course selection :"<<endl;
cout<<"1. Course selection "<<endl;
cout<<"0.return"<<endl;
cin>>select;
cin.get();
if(select==0)return;
cout<<"select Student number :";
getline(cin,stnum,'\n');
cout<<"select Course number :";
getline(cin,coursenum,'\n');
coursepos=cr.searchcoursebynump(coursenum);
stpos=st.searchstudentbynump(stnum);
if(coursepos>=0&&stpos>=0){
int hm=cr.course[coursepos].getCourse_people();
int hn=cr.course[coursepos].getPeople();
if(hm>hn){
stname=st.student[stpos].getName();
coursetitle=cr.course[coursepos].getTitle();
term=cr.course[coursepos].getTerm();
choice=0;
cr.course[coursepos].setPeople(hn+1); // Modify the number of selected courses in the course information table
sc.selectcourse[sc.selectcoursecount].setNum(stnum);
sc.selectcourse[sc.selectcoursecount].setName(stname);
sc.selectcourse[sc.selectcoursecount].setCourseNum(coursenum);
sc.selectcourse[sc.selectcoursecount].setCourseTitle(coursetitle);
sc.selectcourse[sc.selectcoursecount].setTerm(term);
sc.selectcourse[sc.selectcoursecount].setChoice(choice);
sc.selectcoursecount++;
sc.selectcourse[sc.selectcoursecount-1].dispSelectCourse();
cout<<" Successful course selection "<<endl;
}
else cout<<coursenum<<" Course capacity <= The number of students who choose courses "<<". can't be selected. "<<endl;
}
else{
if(coursepos<0)cout<<"No course "<<coursenum<<". can't select!"<<endl;
if(stpos<0)cout<<"No student "<<stnum<<". can't select!"<<endl;
}
}
}
void studentdropacourse(){
cout<<"10. Student withdrawal : Enter the student id + Course number , Modify the number of selected courses in the course information table -1, Set the withdrawal of students with this student number from the course in the student selection table "<<endl;
string stnum="20132947",coursenum="BF002345",stname,coursetitle,term;
int choice;
int select,stpos,coursepos,stcoursepos;
while(1){
cout<<" Student withdrawal :"<<endl;
cout<<"1. The drop "<<endl;
cout<<"0.return"<<endl;
cin>>select;
cin.get();
if(select==0)return;
cout<<"return Student number :";
getline(cin,stnum,'\n');
cout<<"return Course number :";
getline(cin,coursenum,'\n');
coursepos=cr.searchcoursebynump(coursenum);
stpos=st.searchstudentbynump(stnum);
stcoursepos=sc.searchbynump(stnum);
if(coursepos>=0&&stpos>=0&&stcoursepos>=0){
choice=1;
cr.course[coursepos].setPeople(cr.course[coursepos].getPeople()-1);
sc.selectcourse[stcoursepos].setChoice(choice);
sc.selectcourse[stcoursepos].dispSelectCourse();
cout<<" Successful withdrawal "<<endl;
}
else{
if(coursepos<0)cout<<"No course "<<coursenum<<". can't drop!"<<endl;
if(stpos<0)cout<<"No student "<<stnum<<". can't drop!"<<endl;
}
}
}
void searchstudentselectcourse(){
cout<<"11. Student course selection query : By student number 、 Course number 、 Professional classes, etc ."<<endl;
char tit[80];
string num="20136954",coursenum="BF002345",classno=" In the letter 13-1";
int i,j,k,select;
while(1){
cout<<" Student course selection query :"<<endl;
cout<<"1. By student number "<<endl;
cout<<"2. Query by course number "<<endl;
cout<<"3. Query by professional class "<<endl;
cout<<"0. return"<<endl;
cin>>select;
cin.get();
switch(select){
case 1:
cout<<" Student number :";
getline(cin,num,'\n');
sc.searchbynum(num);
break;
case 2:
cout<<" Course number :";
getline(cin,coursenum,'\n');
sc.searchbycoursenum(coursenum);
break;
case 3:
cout<<" Professional class :";
getline(cin,classno,'\n');
sc.searchbyclassno(classno);
break;
case 0:return;
}
}
}
};
int main()
{
StudentSelectCourse ssc;
ssc.init();
ssc.dispCourse();
ssc.dispStudent();
ssc.dispSelectCourse();
ssc.dispCount();
int select;
while(1){
cout<<" Menu selection function :"<<endl;
cout<<"1. Add function of course information : Include course number 、 Course name 、 Course nature 、 Total class hours 、 Theoretical hours 、 Experimental hours 、 The first semester 、 Start and end weeks 、 Class capacity 、 Number of selected courses, etc "<<endl;
cout<<"2. Course information query : According to the course number 、 Course name, etc ."<<endl;
cout<<"3. Course information sorting : By course number , Sort by course name, etc. in ascending order ."<<endl;
cout<<"4. Modification of course information 、 Delete : Course number , Modify and delete books according to the course name ."<<endl;
cout<<"5. Student information adding function : Including student ID 、 full name 、 college 、 Professional classes, etc ."<<endl;
cout<<"6. Student information inquiry : By student number 、 full name 、 Class, etc ."<<endl;
cout<<"7. Student information ranking : According to the student id 、 Colleges, etc. are sorted in ascending order ."<<endl;
cout<<"8. Modification of student information 、 Delete : According to the student id + Name to modify and delete student information ."<<endl;
cout<<"9. Students' course selection : Enter the student id + Course number , If the course capacity in the course information table of the course is greater than the number of selected courses , You can choose courses , Modify the number of selected courses in the course information table after selecting courses +1, Add the student's course selection in the student's course selection table ."<<endl;
cout<<"10. Student withdrawal : Enter the student id + Course number , Look up the student's selection of course number in the student selection table , If there is , Then modify the number of selected courses in the course information table -1, Set the withdrawal of students with this student number from the course in the student selection table ( The deselection flag is set to 1)."<<endl;
cout<<"11. Student course selection query : By student number 、 Course number 、 Professional classes, etc ."<<endl;
cout<<"0. exit"<<endl;
cin>>select;
switch(select){
case 1:ssc.addcourse(); ssc.dispCount();break;
case 2:ssc.searchcourse();break;
case 3:ssc.sortcourse();break;
case 4:ssc.editcourse();break;
case 5:ssc.addstudent(); ssc.dispCount();break;
case 6:ssc.searchstudent();break;
case 7:ssc.sortstudent();break;
case 8:ssc.editstudent();break;
case 9:ssc.studentselectacourse();break;
case 10:ssc.studentdropacourse();break;
case 11:ssc.searchstudentselectcourse();break;
case 0:ssc.write2file();exit(0);
}
}
return 0;
}
边栏推荐
- Best practices for building multi architecture images
- 历史上的今天:支付宝推出条码支付;分时系统之父诞生;世界上第一支电视广告...
- Kubernetes family container housekeeper pod online Q & A?
- Data Lake (11): Iceberg table data organization and query
- By asp Net core downloads files according to the path exception
- Another graduation season
- 台积电全球员工薪酬中位数约46万,CEO约899万;苹果上调日本的 iPhone 售价 ;Vim 9.0 发布|极客头条...
- mysql 计算经纬度范围内的数据
- PCL 点云镜像变换
- Route service grid traffic through two-level gateway design
猜你喜欢
PyC file decompile
The light of ideal never dies
[fluent] dart data type string type (string definition | string splicing | string API call)
历史上的今天:支付宝推出条码支付;分时系统之父诞生;世界上第一支电视广告...
微信v3native支付设置的结束时间处理办法
Original God 2.6 server download and installation tutorial
数学分析_笔记_第5章:一元微分学
Remove the underline in router link
Understand the key technology of AGV -- the difference between laser slam and visual slam
Practice of traffic recording and playback in vivo
随机推荐
PCL 点云镜像变换
理想之光不灭
mysql min() 求某条件下最小的值出现多个结果
Invalid bound statement (not found)解决方法总结
Vscade set multi line display of tab
源码look me
Solve * * warning * *: your ApplicationContext is unlikely to start due to a @componentscan of the defau
What is the difference between self attention mechanism and fully connected graph convolution network (GCN)?
TypeScript数组乱序输出
Huawei ECS installs mysqlb for mysqld service failed because the control process exited with error code. See “sys
Song of cactus - throwing stones to ask the way (3)
Best practices for building multi architecture images
win10系统升级一段时间后,内存占用过高
sim2real环境配置教程
Write your own CPU Chapter 11 - learning notes
仙人掌之歌——投石问路(2)
Aike AI frontier promotion (2.15)
HMS core machine learning service helps zaful users to shop conveniently
去除router-link中的下划线
微信v3native支付设置的结束时间处理办法