代码拉取完成,页面将自动刷新
#include"day.h"
using namespace std;
//构造函数
day::day() = default;//用到了
//显示日程
void day::display_personal_schedule(unsigned int display_day_number)const
{
std::cout << display_day_number << "号:";
if(get_personal_schedule_number() == 0)
{
/*std::cout << "无个人" << std::endl;*/
}
else
{
std::cout << get_personal_schedule_number() << "个人" << std::endl;
int i = 1;
for(auto ele :schedule_vec)
{
if (ele.gettype() == "person")
{
std::cout << ele.getevent() << "~" <<
ele.gettime() << "~" << ele.getsite() <<"~"<<ele.getbeizhu()<< "..............................." <<i << std::endl;
++i;
}
}
}
}
void day::display_team_schedule(unsigned int display_day_number) const
{
std::cout << display_day_number << "号:";
if (get_team_schedule_number() == 0)
{
/*std::cout << "无团队" << std::endl;*/
}
else
{
std::cout << get_team_schedule_number() << "团队" << std::endl;
int i = 1;
for (auto ele :schedule_vec)
{
if (ele.gettype() == "team")
{
std::cout << ele.getevent() << "~" <<
ele.gettime() << "~" << ele.getsite() << "~" << ele.getbeizhu() << "..............................." << i << std::endl;
++i;
}
}
}
}
void day::display_schedule(unsigned int display_day_number) const
{
if (get_schedule_number() == 0)
{
cout << "无日程" << endl;
}
else if (get_personal_schedule_number() != 0 && get_team_schedule_number() == 0)
{
cout << "个人:" << endl;
int j = 1;
for (auto ele : get_schedule_vec())
{
if (ele.gettype() == "person")
{
std::cout << ele.getevent() << "~" <<
ele.gettime() << "~" << ele.getsite() << "~" << ele.getbeizhu() << "..............................." << j<< std::endl;
++j;
}
}
/*cout << "无团队" << endl;*/
}
else if (get_personal_schedule_number() == 0 && get_team_schedule_number() != 0)
{
/*cout << "无个人" << endl;*/
cout << "团队:" << endl;
int j = 1;
for (auto ele : get_schedule_vec())
{
if (ele.gettype() == "team")
{
std::cout << ele.getevent() << "~" <<
ele.gettime() << "~" << ele.getsite() << "~" << ele.getbeizhu() << "..............................." << j << std::endl;
++j;
}
}
}
else
{
cout << "个人:" << endl;
int j = 1;
for (auto ele : get_schedule_vec())
{
if (ele.gettype() == "person")
{
std::cout << ele.getevent() << "~" <<
ele.gettime() << "~" << ele.getsite() << "~" << ele.getbeizhu() << "..............................." << j << std::endl;
++j;
}
}
cout << "团队:" << endl;
j = 1;
for (auto ele : get_schedule_vec())
{
if (ele.gettype() == "team")
{
std::cout << ele.getevent() << "~" <<
ele.gettime() << "~" << ele.getsite() << "~" << ele.getbeizhu() << "..............................." << j << std::endl;
++j;
}
}
}
}
//添加日程
bool day::add_personal_schedule()
{
std::string event,time,site,beizhu;
std::cout << "事件:";
std::getline(std::cin,event);
if(string_is_space(event))
{
std::cout << f_red << "操作失败:事件不能为空!" << reset << std::endl;
return false;
}
std::cout << "时间:";
std::getline(std::cin,time);
std::cout << "地点:";
std::getline(std::cin,site);
std::cout << "备注:";
std::getline(std::cin, beizhu);
schedule_vec.emplace_back(schedule("person",event, time, site,beizhu));
return true;
}
bool day::add_team_schedule()
{
std::string event, time, site,beizhu;
std::cout << "事件:";
std::getline(std::cin, event);
if (string_is_space(event))
{
std::cout << f_red << "操作失败:事件不能为空!" << reset << std::endl;
return false;
}
std::cout << "时间:";
std::getline(std::cin, time);
std::cout << "地点:";
std::getline(std::cin, site);
std::cout << "备注:";
std::getline(std::cin, beizhu);
schedule_vec.emplace_back(schedule("team", event, time, site,beizhu));
return true;
}
//删除日程
void day::delete_personal_schedule(unsigned int serial_number)
{
auto iter = schedule_vec.cbegin();
unsigned int counter = 0;
unsigned int i = 0;
for (auto& ele :schedule_vec)
{
if (ele.gettype() == "person")
{
++counter;
}
if (counter == serial_number)
{
schedule_vec.erase(iter+i);
}
++i;
}
std::cout << f_red << "操作失败:输入格式错误!" << reset << std::endl;
}
void day::delete_team_schedule(unsigned int serial_number)
{
auto iter = schedule_vec.cbegin();
unsigned int counter = 0;
unsigned int i = 0;
for (auto& ele : schedule_vec)
{
if (ele.gettype() == "team")
{
++counter;
}
if (counter == serial_number)
{
schedule_vec.erase(iter + i);
}
++i;
}
std::cout <<f_red<< "操作失败:输入格式错误!" << reset << std::endl;
}
//清空日程
void day::clear_personal_schedule()
{
auto new_end = std::remove_if(schedule_vec.begin(), schedule_vec.end(), [](auto& s){return s.gettype() == "person"; });
schedule_vec.erase(new_end, schedule_vec.end());
}
void day::clear_team_schedule()
{
auto new_end = std::remove_if(schedule_vec.begin(), schedule_vec.end(), [](auto& s){return s.gettype() == "team"; });
schedule_vec.erase(new_end, schedule_vec.end());
}
//判断日程是否为空
bool day::is_personal_schedule_empty() const
{
if (get_personal_schedule_number() == 0)
{
return true;
}
else
{
return false;
}
}
bool day::is_team_schedule_empty() const
{
if (get_team_schedule_number() == 0)
{
return true;
}
else
{
return false;
}
}
bool day::is_empty()const
{
return day::is_personal_schedule_empty() && day::is_team_schedule_empty();
}
//修改日程
bool day::modify_personal_schedule(unsigned int serial_number)
{
auto iter = schedule_vec.begin();
unsigned int counter = 0;
unsigned int i = 0;
for (auto& ele : schedule_vec)
{
if (ele.gettype() == "person")
{
++counter;
}
if (counter == serial_number)
{
std::string event, time, site,beizhu;
std::cout << "事件:";
std::getline(std::cin, event);
if (string_is_space(event))
{
std::cout << f_red << "操作失败:事件不能为空!" << reset << std::endl;
return false;
}
std::cout << "时间:";
std::getline(std::cin, time);
std::cout << "地点:";
std::getline(std::cin, site);
std::cout << "备注:";
std::getline(std::cin, beizhu);
(iter + i)->setevent(event);
(iter + i)->settime(time);
(iter + i)->setsite(site);
(iter + i)->setbeizhu(beizhu);
return true;
}
++i;
}
std::cout << f_red << "操作失败:输入格式错误!" << reset << std::endl;
return false;
}
bool day::modify_team_schedule(unsigned int serial_number)
{
auto iter = schedule_vec.begin();
unsigned int counter = 0;
unsigned int i = 0;
for (auto& ele : schedule_vec)
{
if (ele.gettype() == "team")
{
++counter;
}
if (counter == serial_number)
{
std::string event, time, site,beizhu;
std::cout << "事件:";
std::getline(std::cin, event);
if (string_is_space(event))
{
std::cout << f_red << "操作失败:事件不能为空!" << reset << std::endl;
return false;
}
std::cout << "时间:";
std::getline(std::cin, time);
std::cout << "地点:";
std::getline(std::cin, site);
std::cout << "备注:";
std::getline(std::cin, beizhu);
(iter + i)->setevent(event);
(iter + i)->settime(time);
(iter + i)->setsite(site);
(iter + i)->setbeizhu(beizhu);
return true;
}
++i;
}
std::cout << f_red << "操作失败:输入格式错误!" << reset << std::endl;
return false;
}
//获取个人数
const unsigned int day::get_personal_schedule_number()const
{
unsigned int counter = 0;
for (auto& ele :schedule_vec)
{
if (ele.gettype() == "person")
++counter;
}
return counter;
}
unsigned int day::get_personal_schedule_number()
{
unsigned int counter = 0;
for (auto& ele : schedule_vec)
{
if (ele.gettype() == "person")
++counter;
}
return counter;
}
const unsigned int day::get_team_schedule_number() const
{
unsigned int counter = 0;
for (auto& ele :schedule_vec)
{
if (ele.gettype() == "team")
++counter;
}
return counter;
}
unsigned int day::get_team_schedule_number()
{
unsigned int counter = 0;
for (auto& ele : schedule_vec)
{
if (ele.gettype() == "team")
++counter;
}
return counter;
}
const unsigned int day::get_schedule_number()const
{
return day::get_personal_schedule_number() + day::get_team_schedule_number();
}
unsigned int day::get_schedule_number()
{
return day::get_personal_schedule_number() + day::get_team_schedule_number();
}
//返回personal_schedule_vec
const std::vector<schedule> & day::get_schedule_vec()const
{
return schedule_vec;
}
std::vector<schedule> & day::get_schedule_vec()
{
return schedule_vec;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。