1 Star 1 Fork 0

yxyc-137/Team collaboration calendar

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
month.cpp 10.57 KB
一键复制 编辑 原始数据 按行查看 历史
#include"month.h"
using namespace std;
month::month()//未用到
:day_vec(30,day()),year_number(1),month_number(1),xingqi(1){}
month::month(unsigned int y,unsigned int m)
:year_number(y),month_number(m),xingqi(get_xingqi(year_number,month_number))
{
if(y % 4 == 0)//闰年
{
switch(m)
{
case 2:
day_vec.assign(29,day());break;
case 4:
case 6:
case 9:
case 11:
day_vec.assign(30,day());break;
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
day_vec.assign(31,day());break;
default:
std::cout << "操作失败!" << std::endl;
break;
}
}
else//非闰年
{
switch(m)
{
case 2:
day_vec.assign(28,day());break;
case 4:
case 6:
case 9:
case 11:
day_vec.assign(30,day());break;
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
day_vec.assign(31,day());break;
default:
std::cout << "操作失败!" << std::endl;
break;
}
}
}
//操作
// 返回day_vec
std::vector<day> & month::get_day_vec()
{
return day_vec;
}
const std::vector<day> & month::get_day_vec()const
{
return day_vec;
}
// 返回该月天数
unsigned int month::get_day_vec_size()
{
return day_vec.size();
}
//显示一个月的日程情况
void month::display_month()//不能为const
{
/*std::cout <<" " << "***********" << std::endl;*/
std::cout << std::setw(65) <<"*"<< year_number << "年" << month_number << "月*" << std::endl;
std::cout << " ------------------------------------------------------------------------------------------------------------------" << std::endl;
for(int i = 1;i <= 7;++i,++xingqi)
{
if(get_xingqi(xingqi) == "六" || get_xingqi(xingqi) == "日")
{
std::cout << f_qingse;
}
std::cout << std::setw(17)<< get_xingqi(xingqi) ;
std::cout << reset;
}
std::cout << '\n';
std::cout << " ------------------------------------------------------------------------------------------------------------------" << std::endl;
auto days = day_vec.size();
int i = 1;
for(auto & ele : day_vec)
{
if(month_number == 1 && i == 1)
{
if(year_number==now_year&&month_number==now_month && i == now_day)
{
std::cout << f_purple << std::setw(17) << "today(元旦)" << reset;
}
else if(!day_vec[i - 1].is_empty())
{
std::cout << f_yellow << std::setw(17) << "元旦" << reset;
}
else
{
std::cout << std::setw(17) << "元旦"<<reset;
}
}
else if(month_number == 2 && i == 14)
{
if(year_number==now_year&&month_number==now_month && i == now_day)
{
std::cout << f_purple << std::setw(17) << "today(情人)" << reset;
}
else if(!day_vec[i - 1].is_empty())
{
std::cout << f_yellow << std::setw(17) << "情人" << reset;
}
else
{
std::cout << std::setw(17) << "情人"<<reset;
}
}
else if(month_number == 3 && i == 8)
{
if(year_number==now_year&&month_number==now_month && i == now_day)
{
std::cout << f_purple << std::setw(17) << "today(妇女)" << reset;
}
else if(!day_vec[i - 1].is_empty())
{
std::cout << f_yellow << std::setw(17) << "妇女" << reset;
}
else
{
std::cout<<std::setw(17)<<"妇女"<<reset;
}
}
else if(month_number == 3 && i == 12)
{
if(year_number==now_year&&month_number==now_month && i == now_day)
{
std::cout << f_purple << std::setw(17) << "today(植树)" << reset;
}
else if(!day_vec[i - 1].is_empty())
{
std::cout << f_yellow << std::setw(17) << "植树" << reset;
}
else
{
std::cout<<std::setw(17)<<"植树"<<reset;
}
}
else if(month_number == 4 && i == 1)
{
if(year_number==now_year&&month_number==now_month && i == now_day)
{
std::cout << f_purple << std::setw(17) << "today(愚人)" << reset;
}
else if(!day_vec[i - 1].is_empty())
{
std::cout << f_yellow << std::setw(17) << "愚人" << reset;
}
else
{
std::cout<<std::setw(17)<<"愚人"<<reset;
}
}
else if(month_number == 5 && i == 1)
{
if(year_number==now_year&&month_number==now_month && i == now_day)
{
std::cout << f_purple << std::setw(17) << "today(劳动)" << reset;
}
else if(!day_vec[i - 1].is_empty())
{
std::cout << f_yellow << std::setw(17) << "劳动" << reset;
}
else
{
std::cout<<std::setw(17)<<"劳动"<<reset;
}
}
else if(month_number == 5 && i == 4)
{
if(year_number==now_year&&month_number==now_month && i == now_day)
{
std::cout << f_purple << std::setw(17) << "today(青年)" << reset;
}
else if(!day_vec[i - 1].is_empty())
{
std::cout << f_yellow << std::setw(17) << "青年" << reset;
}
else
{
std::cout<<std::setw(17)<<"青年"<<reset;
}
}
else if(month_number == 5 && i == 14)
{
if(year_number==now_year&&month_number==now_month && i == now_day)
{
std::cout << f_purple << std::setw(17) << "today(母亲)" << reset;
}
else if(!day_vec[i - 1].is_empty())
{
std::cout << f_yellow << std::setw(17) << "母亲" << reset;
}
else
{
std::cout<<std::setw(17)<<"母亲"<<reset;
}
}
else if(month_number == 6 && i == 1)
{
if(year_number==now_year&&month_number==now_month && i == now_day)
{
std::cout << f_purple << std::setw(17) << "today(儿童)" << reset;
}
else if(!day_vec[i - 1].is_empty())
{
std::cout << f_yellow << std::setw(17) << "儿童" << reset;
}
else
{
std::cout<<std::setw(17)<<"儿童"<<reset;
}
}
else if(month_number == 6 && i == 18)
{
if(year_number==now_year&&month_number==now_month && i == now_day)
{
std::cout << f_purple << std::setw(17) << "today(父亲)" << reset;
}
else if(!day_vec[i - 1].is_empty())
{
std::cout << f_yellow << std::setw(17) << "父亲" << reset;
}
else
{
std::cout<<std::setw(17)<<"父亲"<<reset;
}
}
else if(month_number == 7 && i == 1)
{
if(year_number==now_year&&month_number==now_month && i == now_day)
{
std::cout << f_purple << std::setw(17) << "today(建党)" << reset;
}
else if(!day_vec[i - 1].is_empty())
{
std::cout << f_yellow << std::setw(17) << "建党" << reset;
}
else
{
std::cout<<std::setw(17)<<"建党"<<reset;
}
}
else if(month_number == 8 && i == 1)
{
if(year_number==now_year&&month_number==now_month && i == now_day)
{
std::cout << f_purple << std::setw(17) << "today(建军)" << reset;
}
else if(!day_vec[i - 1].is_empty())
{
std::cout << f_yellow << std::setw(17) << "建军" << reset;
}
else
{
std::cout<<std::setw(17)<<"建军"<<reset;
}
}
else if(month_number == 9 && i == 10)
{
if(year_number==now_year&&month_number==now_month && i == now_day)
{
std::cout << f_purple << std::setw(17) << "today(教师)" << reset;
}
else if(!day_vec[i - 1].is_empty())
{
std::cout << f_yellow << std::setw(17) << "教师" << reset;
}
else
{
std::cout<<std::setw(17)<<"教师"<<reset;
}
}
else if(month_number == 10 && i == 1)
{
if(year_number==now_year&&month_number==now_month && i == now_day)
{
std::cout << f_purple << std::setw(17) << "today(国庆)" << reset;
}
else if(!day_vec[i - 1].is_empty())
{
std::cout << f_yellow << std::setw(17) << "国庆" << reset;
}
else
{
std::cout<<std::setw(17)<<"国庆"<<reset;
}
}
else if(month_number == 10 && i == 31)
{
if(year_number==now_year&&month_number==now_month && i == now_day)
{
std::cout << f_purple << std::setw(17) << "today(万圣)" << reset;
}
else if(!day_vec[i - 1].is_empty())
{
std::cout << f_yellow << std::setw(17) << "万圣" << reset;
}
else
{
std::cout<<std::setw(17)<<"万圣"<<reset;
}
}
else if(month_number ==11 && i == 23)
{
if(year_number==now_year&&month_number==now_month && i == now_day)
{
std::cout << f_purple << std::setw(17) << "today(感恩)" << reset;
}
else if(!day_vec[i - 1].is_empty())
{
std::cout << f_yellow << std::setw(17) << "感恩" << reset;
}
else
{
std::cout<<std::setw(17)<<"感恩"<<reset;
}
}
else if(month_number == 12 && i == 24)
{
if(year_number==now_year&&month_number==now_month && i == now_day)
{
std::cout << f_purple << std::setw(17) << "today(平安)" << reset;
}
else if(!day_vec[i - 1].is_empty())
{
std::cout << f_yellow << std::setw(17) << "平安" << reset;
}
else
{
std::cout<<std::setw(17)<<"平安"<<reset;
}
}
else if(month_number == 12 && i == 25)
{
if(year_number == now_year && month_number == now_month && i == now_day)
{
std::cout << f_purple << std::setw(17) << "today(圣诞)" << reset;
}
else if(!day_vec[i - 1].is_empty())
{
std::cout << f_yellow << std::setw(17) << "圣诞" << reset;
}
else
{
std::cout << std::setw(17) << "圣诞" << reset;
}
}//当是节日的情况
else
{
if(year_number==now_year&&month_number==now_month&&i == now_day)
{
std::cout << f_purple << std::setw(17) << "today" << reset;
}
else if(!day_vec[i - 1].is_empty())
{
std::cout << f_yellow << std::setw(15) << i << "号" << reset;
}
else
{
std::cout << std::setw(15) << i << "号";
}
}
if(i % 7 == 0)
{
std::cout << std::endl;
for(int j = i - 6 - 1;j != i;++j)
{
if(year_number==now_year&&month_number==now_month&&j == now_day - 1)
{
std::cout << f_purple << std::setw(17) <<to_string( day_vec[j].get_schedule_number() )<< reset;
}
else
{
if(day_vec[j].is_empty())
{
std::cout<<std::setw(17)<<"0";
}
else
{
std::cout << f_yellow << std::setw(17) << day_vec[j].get_schedule_number() << reset;
}
}
}
std::cout << std::endl;
}
else if(i == day_vec.size())
{
std::cout << std::endl;
for(int j = 29; j != i + 1; ++j)
{
if(year_number == now_year && month_number == now_month && j == now_day )
{
std::cout << f_purple << std::setw(17) <<to_string( day_vec[j-1].get_schedule_number()) << reset;
}
else{
if(day_vec[j - 1].is_empty())
{
std::cout << std::setw(17) << "0";
}
else
{
std::cout << f_yellow << std::setw(17) << day_vec[j - 1].get_schedule_number() << reset;
}
}
}
std::cout << std::endl;
}
++i;
}
std::cout << " ------------------------------------------------------------------------------------------------------------------" << std::endl;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/yxyc-137/Team_collaboration_calendar.git
git@gitee.com:yxyc-137/Team_collaboration_calendar.git
yxyc-137
Team_collaboration_calendar
Team collaboration calendar
master

搜索帮助