Student management system

Keywords: Cpp

;

Project introduction:
When the project was a freshman year, the cpp course design assignment. At that time, the understanding of cpp was weak, and the grasp of the framework of the large project was not very good, so there may be many irregularities or errors in the code. The purpose of uploading is to give some code ideas to students who need to do relevant course design, and you are welcome to criticize and correct.

1. Code file list

2. Code framework description

  1. Student_System
    Contains the main function, which is used to start the terminal.

  2. interface
    Human computer interaction file is used to draw menu interface and write function switching logic.

  3. school
    School class, the main function is to create information documents of colleges, classes and various courses.

  4. academy
    College class, the main function is to create a designated college and manage the courses of the college.

  5. edu_administration
    Educational administration class, the main functions are to create educational administrators, manage student files, find student information, view and modify student course scores, etc

  6. class
    Class class, the main function is to create classes, manage class student information, view class student performance ranking, etc

  7. student
    Student class, the main functions are to create students, view personal performance ranking, elective courses, view timetable, modify personal information, etc

3. Important code description
Because the code is too long, only part of the core code is excerpted here for description, and the complete project file can be downloaded at the end of the text

(1) Information reading and storage
The data reading and writing of the project documents are based on the cpp file management library fstream. The specific implementation is as follows

  1. Write case
//Create class
void Class::Build_Classes(const std::string & academy_name)
{

	using namespace std;
	ofstream oclassf;
	int class_num;
	string filename;
	cout << "Please enter the class number: ";
	cin >> class_num;
	filename = "SCUT\\college\\" + academy_name + "\\class\\" + academy_name + "_" + to_string(class_num) + "_class" + ".txt";
	oclassf.open(filename, ios::out | ios::binary);
	if (!oclassf)
	{
		cerr << "File can not be opened." << endl;
		abort();
	}
	oclassf << to_string(class_num) << "Class document" << endl;
	oclassf.close();
	filename = "SCUT\\college\\" + academy_name + "\\archives\\" + academy_name + "_Educational administration archives" + ".txt";
	oclassf.open(filename, ios::app | ios::binary);
	if (!oclassf)
	{
		cerr << "File can not be opened." << endl;
		abort();
	}
	oclassf << class_num << " ";
	cout << academy_name << class_num << "Class created successfully" << endl;
}
  1. Read case
//Print course schedule
void Student::Print_Courses(void)
{
	using namespace std;
	int i, count = 0;
	char s[80];
	string filename , temp, ID;
	ifstream ifcourse;
	filename = "SCUT\\college\\" + academy_name + "\\curriculum\\" + academy_name + "__curriculum" + ".txt";
	ifcourse.open(filename, ios::in | ios::binary);
	if (!ifcourse)
	{
		cerr << "File can not be opened." << endl;
		abort();
	}
	for (i = 0; i < 3; i++) ifcourse.getline(s, 80);	//Filter out the title + read the first line
	while (s[0])
	{
		count++;
		ifcourse.getline(s, 80);
	}
	ifcourse.close();
	ifcourse.open(filename, ios::in | ios::binary);
	string ** lessons = new string* [count];
	int ** lesson_time = new int * [count];
	for (i = 0; i < count; i++)
	{
		lesson_time[i] = new int[2];
		lessons[i] = new string[3];
	}
	for (i = 0; i < 2; i++) ifcourse.getline(s, 80);	//Filter out the title
	for (i = 0; i < count; i++)
	{
		ifcourse >> lessons[i][0] >> temp >> lessons[i][1] >> temp >> lessons[i][2]
			>> temp >> lesson_time[i][0] >> lesson_time[i][1];
	}
	ifcourse.close();
	for (i = 0; i < count; i++)
	{
		if (lessons[i][1] == "0")
		{
			filename = "SCUT\\college\\" + academy_name + "\\curriculum\\Course achievement\\Elective courses\\" + lessons[i][0] + "_" + "_achievement" + ".txt";
			ifcourse.open(filename, ios::in);
			if (!ifcourse)
			{
				cerr << "File can not be opened." << endl;
				abort();
			}
			while (ifcourse >> ID)
			{
				if (ID == stu.ID) break;
			}
			if (ID == stu.ID) lessons[i][1] = "1";
			ifcourse.close();
		}
	}
	//Print
	Class_Schedule(lesson_time, lessons, count);
	for (i = 0; i < count; i++)
	{
		delete[]lessons[i];
		delete[]lesson_time[i];
	}
	delete[]lessons;
	delete[]lesson_time;
}

(2) Create data folder for management system
If all kinds of documents and files are stored in one folder, it will appear very scattered, so I use the system command to create folders recursively.

//Create College
void School::Build_Academy(std::string academy_name)
{
	using namespace std;
	ofstream ofschool;
	string command;
	command = "mkdir SCUT\\college\\" + academy_name;
	system(command.c_str());		//college
	command = "mkdir SCUT\\college\\" + academy_name + "\\class";
	system(command.c_str());		
	command = "mkdir SCUT\\college\\" + academy_name + "\\curriculum";
	system(command.c_str());	
	command = "mkdir SCUT\\college\\" + academy_name + "\\archives";
	system(command.c_str());
	command = "mkdir SCUT\\college\\" + academy_name + "\\curriculum\\Course achievement";
	system(command.c_str());		
	command = "mkdir SCUT\\college\\" + academy_name + "\\curriculum\\Course achievement\\required course";
	system(command.c_str());		
	command = "mkdir SCUT\\college\\" + academy_name + "\\curriculum\\Course achievement\\Elective courses";
	system(command.c_str());	
	Build_Lessons(academy_name);
	Build_Student_File(academy_name);
	Build_Admini_File(academy_name);
}

Other codes will not be repeated, and finally put the complete project file
Student management system project source code

Posted by mhenke on Sat, 04 Sep 2021 21:30:49 -0700