⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 course.cpp

📁 用C++写的一个简单学籍管理系统
💻 CPP
字号:
#include "course.h"
#include <assert.h>

Course::Course(char *name ,const int id, const float score)
:name(name),id(id),score(score),teacher("some",-1,MALE)
{
	assert(score>=0.0&&score<=100.0);
}
Course::Course( string name,const int id/* =-1 */,const float score/* =0.0  */)
:name(name),id(id),score(score),teacher("some",-1,MALE)
{
}
Course::Course(const Course &  c)
:name(c.name),id(c.id),score(c.score),teacher(c.teacher)
{
	assert(score>=0.0&&score<=100.0);
}

Course::~Course()
{
}

Course & Course::operator =(const Course & c)
{
	name = c.name;
	id = c.id;
	score = c.score;
	teacher = c.teacher;
	cout<<"Course = Course"<<endl;
	return *this;
}

bool Course::operator ==( const Course &c )
{
	return (id == c.id); // 课程号唯一
}

const string Course::getName()const
{
	return name;
}

const int Course::getId()const
{
	return id;
}
const float Course::getScore()const
{
	return score;
}
const Teacher & Course::getTeacher()const
{
	return teacher;
}
void Course::setId(const int id)
{
	Course::id = id;
}

void Course::setName(const string name)
{
	Course::name = name;
}

void Course::setScore( const float score)
{
	Course::score = score;
}
void Course::setTeacher( const Teacher& t)
{
	teacher = t;
}

void Course::write( ostream &os)
{
	os<<name<<"#";
	os<<id<<"#";
	os<<score<<"#";
	teacher.write(os);
}
void Course::read( istream &is)
{
	char tpName[20];  // 课程名不超过20个字符
	is.get(tpName,20,'#');
	name= tpName;
	is.ignore();
	is>>id;
	is.ignore();
	is>>score;
	is.ignore();
	teacher.read(is);
}
void Course::printBase()
{
	cout<<setw(20)<<id<<setw(20)<<name;
}
void Course::printDetail()
{
	printBase();
	cout<<setw(20)<<score<<setw(20)<<teacher.getName();
}
/*list<Course>& operator=(list<Course>& self,const list<Course>& ref)
{
	list<Course>::const_iterator iBegin = ref.begin();
	list<Course>::const_iterator iEnd = ref.end();
	self.clear();
	while (iBegin!=iEnd)
	{
		Course c= *iBegin;
		self.push_back(c);
		iBegin++;
	}
}
*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -