1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
//weekDay.cpp
#include<iostream>
using namespace std;
#include "weekDay.h"
weekDay::weekDay(string weekday)
{
day=weekday;
}
void weekDay :: set(string weekday){
day=weekday;
}
void weekDay :: print() const{
cout<<day<<" ";
}
string weekDay :: get() const{
return day;
}
string weekDay :: getNext() const{
string weekday[7]={"Sat","Sun","Mon","Tue","Wed","Thu","Fri"};
for (int i=0; i<7; i++){
if (weekday[i]==day)
if(i==6)
day=weekday[0];
day=weekday[i+1];
}
return day;
}
string weekDay :: getPrevious() const{
string weekday[7]={"Sat","Sun","Mon","Tue","Wed","Thu","Fri"};
for (int i=0; i<7; i++){
if (weekday[i]==day)
if(i==0)
day=weekday[6];
day=weekday[i-1];
}
return day;
}
string weekDay :: add(const int _days) const{
string weekday[7]={"Sat","Sun","Mon","Tue","Wed","Thu","Fri"};
for (int i=0; i<7; i++){
int j=i;
if (weekday[i]==day){
for(int k=0; k<(_days-i); k++){
if (j==7)
j=0;
j++;
}}
day=weekday[j];
return day;
break;
}
}
|