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

📄 homeworklist.cpp

📁 SSD5 中EX1的参考答案 下载后请参照注释认真分析
💻 CPP
字号:
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>

#include "homeworklist.h"

using namespace std;

homeworklist::homeworklist()
{
	current_size = 0;
}
    
bool homeworklist:: add (homework h)
{
	if(current_size < LIST_MAX)
	{
		list[current_size] = h;
		current_size++;
		return 1;
	}
	else
	{
		return false;
	}
}

    
homeworklist homeworklist:: dueafter (date d)
{
	homeworklist hl = homeworklist();
	int dateBool;
	date d1 = date();
	homework cmpDate = homework("",d1,d);
	for(int i=0;i<current_size;i++)
	{
		dateBool = list[i].compareTo(cmpDate);
		if(dateBool == 1)
		{
			hl.add(list[i]);
		}
	}
	return hl;
}


homeworklist homeworklist:: duebefore (date d)
{
	homeworklist hl = homeworklist();
	int dateBool;
	date d1 = date();
	homework cmpDate = homework("",d1,d);
	for(int i=0;i<current_size;i++)
	{
		dateBool = list[i].compareTo(cmpDate);
		if(dateBool == -1)
		{
			hl.add(list[i]);
		}
	}
	return hl;
}


  
homeworklist homeworklist:: dueon (date d)
{
	homeworklist hl = homeworklist();
	int dateBool;
	date d1 = date();
	homework cmpDate = homework("",d1,d);
	for(int i=0;i<current_size;i++)
	{
		dateBool = list[i].compareTo(cmpDate);
		if(dateBool == 0)
		{
			hl.add(list[i]);
		}
	}
	return hl;
}

    
ostream &operator<< (ostream &stream, homeworklist hl)
{
	for(int i = 0 ; i <hl.current_size ; i++)
	{
		stream << hl.list[i] << endl;
	}

	return stream;
}

⌨️ 快捷键说明

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