一、课程设计题目及内容。
学生成绩管理系统
设计要求及提示如下:
(1)、设计一个学生类Student,包括数据成员:姓名、学号、二门课程(面向对象程序设计、高等数学)的成绩。
(2)、创建一个管理学生的类Management,包括实现学生的数据的增加、删除、修改、按课程成绩排序、保存学生数据到文件及加载文件中的数据等功能。
(3)、创建一个基于对话框的MFC应用程序,程序窗口的标题上有你姓名、学号和应用程序名称。使用(1)和(2)中的类,实现对学生信息和成绩的输入和管理。
(4)、创建一个单文档的MFC应用程序,读取(3)中保存的文件中的学生成绩,分别用直方图和折线方式显示所有学生某课程的成绩分布图。
二、每个功能模块的设计分析及算法描述。
创建MFC单文档程序,添加Student类,该类中包括了如下数据成员:学号,姓名,性别,通信地址,年龄,数学成绩,C++成绩,有成员函数实现对这些数据成员的赋值和使用,重载输入输出运算符,使能够输入输出类的对象。
在程序中创建一个对话框,按题目图片布局控件,用按钮实现学生数据的增加、删除、修改,按确定保存文件,程序打开时按鼠标左键显示窗口,同时从文件中读取数据显示到窗口。
在程序的Designview.cpp中添加鼠标左键读取文件功能,在画图函数中把数据用方形图和折线图直观的显示出来。
三、带有详细注释的自己编写的源程序。
Student.h
#include<string>
#include<vector>
enum Sex {
male, female };
class Student
{
public:
Student();
//Get函数返回数据成员,Sex函数赋值
unsigned int GetID() const
{
return mID;
};
void SetID(unsigned int nID)
{
mID = nID;
};
std::string GetName() const
{
return mName;
};
void SetName(const std::string& sName)
{
mName = sName;
};
Sex GetSex() const
{
return mSex;
};
void SetSex(Sex nSex)
{
mSex = nSex;
};
unsigned int GetAge() const
{
return mAge;
};
void SetAge(unsigned int nAge)
{
mAge = nAge;
};
std::string GetAddress() const
{
return mAddr;
};
void SetAddress(const std::string& sAddr)
{
mAddr = sAddr;
};
float GetMath() const
{
return mMath;
};
void SetMath(float nMath)
{
mMath = nMath;
};
float GetCpp() const
{
return mCpp;
};
void SetCpp(float nCpp)
{
mCpp = nCpp;
};
friend std::ostream& operator<<(std::ostream& os, const Student& st); //重载输出运算符
friend std::istream& operator>>(std::istream& is, Student& st); //重载输入运算符
private:
unsigned int mID; //学号
std::string mName; //姓名
Sex mSex; //性别
unsigned int mAge; //年龄
std::string mAddr; //通信地址
float mMath; //数学
float mCpp; //C++
};
Student.cpp
#include "pch.h"
#include "Student.h"
#include<iostream>
Student::Student() :mID(0),mName(""),mSex(male),mAge(18),mAddr(""),mMath(0.0),mCpp(0.0) //初始化
{
}
std::ostream& operator<<(std::ostream& os, const Student& st)
{
os << " " << st.mID;
os << " " << st.mName;
os << " " << (int)st.mSex;
os << " " << st.mAge;
os << " " << st.mAddr;
os << " " << st.mMath;
os << " " << st.mCpp;
return os;
} //输出
std::istream& operator>>(std::istream& is, Student& st)
{
is >> st.mID;
is >> st.mName;
int nSex;
is >> nSex;
st.mSex = nSex == 0 ? male : female;
is >> st.mAge;
is >> st.mAddr;
is >> st.mMath;
is >> st.mCpp;
return is;
} //读取
</