#include"stdafx.h"
#include"CourseList.h"
#include"Student.h"
void CourseList::init_Basic()//初始化基础课列表
{
char buff[1000];
_getcwd(buff, 1000);//得到当前的路径 存在buff中
ifstream OpenFile;
string str(buff);
string temp = str + "\\CMS-Data\\Courses\\基础课\\BasicCourses";
strcpy_s(buff, temp.c_str());
try {
OpenFile.open(buff);
}
catch (exception) {
cerr << "找不到文件!" << endl;
}
string name,id;
int credit, type;
basicN = 0;//初始节点为0
BasicCourseHead = NULL;
Course * ptr = BasicCourseHead;
while (!OpenFile.eof()) {
OpenFile >> name >> id >> credit>>type;
//cout << name << " " << id << " " << credit << " " << type << endl;
Course * course = new Course(name,id,credit,type);
if (basicN == 0) {
BasicCourseHead = course;
ptr = BasicCourseHead;
basicN++;
continue;
}
ptr->next = course;
course->next = NULL;
ptr = ptr->next;
basicN++;//创建完后链表内的节点数+1
}
OpenFile.close();
//cout << "基础类课初始化成功" << endl;
}
void CourseList::init_Major()//初始化专业课列表
{
char buff[1000];
_getcwd(buff, 1000);//得到当前的路径 存在buff中
ifstream OpenFile;
string str(buff);
string temp = str + "\\CMS-Data\\Courses\\专业课\\MajorCourses";
strcpy_s(buff, temp.c_str());
try {
OpenFile.open(buff);
}
catch (exception) {
cerr << "找不到文件!" << endl;
}
string name, id;
int credit, type;
majorN = 0;//初始节点为0
MajorCourseHead = NULL;
Course * ptr = MajorCourseHead;
while (!OpenFile.eof()) {
OpenFile >> name >> id >> credit >> type;
//cout << name << " " << id << " " << credit << " " << type << endl;
Course * course = new Course(name, id, credit, type);
if (majorN == 0) {
MajorCourseHead = course;
ptr = MajorCourseHead;
majorN++;
continue;
}
ptr->next = course;
course->next = NULL;
ptr = ptr->next;
majorN++;//创建完后链表内的节点数+1
}
OpenFile.close();
//cout << "专业类课初始化成功" << endl;
}
void CourseList::init_Optional()//初始化选修课
{
char buff[1000];
_getcwd(buff, 1000);//得到当前的路径 存在buff中
ifstream OpenFile;
string str(buff);
string temp = str + "\\CMS-Data\\Courses\\选修课\\OptionalCourses";
strcpy_s(buff, temp.c_str());
try {
OpenFile.open(buff);
}
catch (exception) {
cerr << "找不到文件!" << endl;
}
string name, id;
int credit, type;
OptN = 0;//初始节点为0
OptionalCourseHead = NULL;
Course * ptr = OptionalCourseHead;
while (!OpenFile.eof()) {
OpenFile >> name >> id >> credit >> type;
//cout << name << " " << id << " " << credit << " " << type << endl;
Course * course = new Course(name, id, credit, type);
if (OptN == 0) {
OptionalCourseHead = course;
ptr = OptionalCourseHead;
OptN++;
continue;
}
ptr->next = course;
course->next = NULL;
ptr = ptr->next;
OptN++;//创建完后链表内的节点数+1
}
OpenFile.close();
//cout << "选修课初始化成功" << endl;
}
void CourseList::init_Humanity()//初始化人文类课程
{
char buff[1000];
_getcwd(buff, 1000);//得到当前的路径 存在buff中
ifstream OpenFile;
string str(buff);
string temp = str + "\\CMS-Data\\Courses\\人文类课程\\HumanityCourses";
strcpy_s(buff, temp.c_str());
try {
OpenFile.open(buff);
}
catch (exception) {
cerr << "找不到文件!" << endl;
}
string name, id;
int credit, type;
HmnN = 0;//初始节点为0
HumanityCourseHead = NULL;
Course * ptr = HumanityCourseHead;
while (!OpenFile.eof()) {
OpenFile >> name >> id >> credit >> type;
//cout << name << " " << id << " " << credit << " " << type << endl;
Course * course = new Course(name, id, credit, type);
if (HmnN == 0) {
HumanityCourseHead = course;
ptr = HumanityCourseHead;
HmnN++;
continue;
}
ptr->next = course;
course->next = NULL;
ptr = ptr->next;
HmnN++;//创建完后链表内的节点数+1
}
OpenFile.close();
//cout << "人文类课初始化成功" << endl;
}
void CourseList::init_Practical()//初始化实践性课程
{
char buff[1000];
_getcwd(buff, 1000);//得到当前的路径 存在buff中
ifstream OpenFile;
string str(buff);
string temp = str + "\\CMS-Data\\Courses\\实践性课程\\PracticalCourses";
strcpy_s(buff, temp.c_str());
try {
OpenFile.open(buff);
}
catch (exception) {
cerr << "找不到文件!" << endl;
}
string name, id;
int credit, type;
PracN = 0;//初始节点为0
PracticalCourseHead = NULL;
Course * ptr = PracticalCourseHead;
while (!OpenFile.eof()) {
OpenFile >> name >> id >> credit >> type;
//cout << name << " " << id << " " << credit << " " << type << endl;
Course * course = new Course(name, id, credit, type);
if (PracN == 0) {
PracticalCourseHead = course;
ptr = PracticalCourseHead;
PracN++;
continue;
}
ptr->next = course;
course->next = NULL;
ptr = ptr->next;
PracN++;//创建完后链表内的节点数+1
}
OpenFile.close();
//cout << "实践类课初始化成功" << endl;
}
void CourseList::init1(string path, Student *stu) {//对学生已选修课程初始化
ifstream OpenFile;
try {
OpenFile.open(path);
}
catch (exception) {
cerr << "找不到文件!" << endl;
}
stuNum = 0;//初始节点为0
basicN = 0;
majorN = 0;
OptN = 0;
HmnN = 0;
PracN = 0;
BasicCourseHead = NULL;
MajorCourseHead = NULL;
OptionalCourseHead = NULL;
HumanityCourseHead = NULL;
PracticalCourseHead = NULL;
Course * ptrBasic = BasicCourseHead;
Course * ptrMajor = MajorCourseHead;
Course * ptrOpt = OptionalCourseHead;
Course * ptrHmn = HumanityCourseHead;
Course * ptrPrac = PracticalCourseHead;
string name,sex,classId,id;
int credit, type;
int basicC;//所修课程类的学分
int majorC;//所修课程类的学分
int OptC;//所修课程类的学分
int HmnC;//所修课程类的学分
int PracC;//所修课程类的学分
int total;
boolean flag = true;//判断是否是第一行
while (!OpenFile.eof()) {
if (flag) {
OpenFile >> name >> sex >> classId >> basicC >> majorC >> OptC >> HmnC >> PracC >> total;
//cout<<name << sex << classId << basicC << majorC << OptC << HmnC << PracC << total;
stu->setName(name);
stu->setSex(sex);
stu->setClass(classId);
stu->setTotalCredir(total);
stu->basicC = basicC;
stu->majorC = majorC;
stu->OptC = OptC;
stu->HmnC = HmnC;
stu->PracC = PracC;
flag = false;
continue;
}
OpenFile >> name >> id >> credit >> type;
//cout << name << id << credit <<"type:"<< type << "Basic:"<<basicN<<" "<<majorN<<endl;
Course * course = new Course(name, id, credit, type);
switch(type) {
case 0: {
if (basicN == 0) {
BasicCourseHead = course;
ptrBasic = BasicCourseHead;
basicC += course->credit;
total+= course->credit;
basicN++;
stuNum++;
break;
}
ptrBasic->next = course;
course->next = NULL;
ptrBasic = ptrBasic->next;
basicC += course->credit;
total += course->credit;
basicN++;//创建完后链表内的节点数+1*/
stuNum++;
break;
}
case 1: {
if (majorN == 0) {
MajorCourseHead = course;
ptrMajor = MajorCourseHead;
majorC += course->credit;
total += course->credit;
majorN++;
stuNum++;
break;
}
ptrMajor->next = course;
course->next = NULL;
ptrMajor = ptrMajor->next;
majorC += course->credit;
total += course->credit;
majorN++;//创建完后链表内的节点数+1*/
stuNum++;
break;
}
case 2: {
if (OptN == 0) {
OptionalCourseHead = course;
ptrOpt = OptionalCourseHead;
OptC+= course->credit;
total += course->credit;
OptN++;
stuNum++;
break;
}
ptrOpt->next = course;
course->next = NULL;
ptrOpt = ptrOpt->next;
OptC += course->credit;
total += course->credit;
OptN++;//创建完后链表内的节点数+1*/
stuNum++;
break;
}
case 3: {
if (HmnN == 0) {
HumanityCourseHead = course;
ptrHmn = HumanityCourseHead;
HmnC+= course->credit;
没有合适的资源?快使用搜索试试~ 我知道了~
学分管理系统-C++课程设计
需积分: 9 485 浏览量
2018-06-18
11:00:46
上传
评论 5
收藏 10.29MB RAR 举报
C++课程设计的大型实验C++课程设计的大型实验C++课程设计的大型实验C++课程设计的大型实验C++课程设计的大型实验C++课程设计的大型实验C++课程设计的大型实验C++课程设计的大型实验C++课程设计的大型实验C++课程设计的大型实验C++课程设计的大型实验C++课程设计的大型实验C++课程设计的大型实验C++课程设计的大型实验C++课程设计的大型实验C++课程设计的大型实验C++课程设计的大型实验C++课程设计的大型实验C++课程设计的大型实验C++课程设计的大型实验C++课程设计的大型实验C++课程设计的大型实验C++课程设计的大型实验C++课程设计的大型实验C++课程设计的大型实验C++课程设计的大型实验C++课程设计的大型实验C++课程设计的大型实验C++课程设计的大型实验C++课程设计的大型实验
资源推荐
资源详情
资源评论




















收起资源包目录


































































































共 76 条
- 1
- 2
- 3
- 4
- 5
- 6
- 16
资源评论

Radioheeader
- 粉丝: 2
- 资源: 5

上传资源 快速赚钱
我的内容管理 收起
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助

会员权益专享
安全验证
文档复制为VIP权益,开通VIP直接复制
