im having some errors with my code. can someone help me fix it? =(
this is my header file:
#include <iostream>
#include <string>
using namespace std;
class dayType{
public:
dayType(string);
void setDay(string);
string printDay();
string prevDay();
void nextDay();
string returnDay();
private:
string weekDay[7];
int currentDay;
string inputDay;
};
dayType::dayType(string){
currentDay = 0;
inputDay = "";
weekDay[7] = {" "};
}
void dayType::setDay(string day){
if(day=="Monday" || day=="MON"){
currentDay = 1;
weekDay[currentDay - 1] = "Monday";
inputDay = day;
}
else if(day=="Tuesday" || day=="TUE"){
currentDay = 2;
weekDay[currentDay - 1] = "Tuesday";
inputDay = day;
}
else if(day=="Wednesday" || day=="WED"){
currentDay = 3;
weekDay[currentDay - 1] = "Wednesday";
inputDay = day;
}
else if(day=="Thursday" || day=="THUR"){
currentDay = 4;
weekDay[currentDay - 1] = "Thursday";
inputDay = day;
}
else if(day=="Friday" || day=="FRI"){
currentDay = 5;
weekDay[currentDay - 1] = "Friday";
inputDay = day;
}
else if(day=="Saturday" || day=="SAT"){
currentDay = 6;
weekDay[currentDay - 1] = "Saturday";
inputDay = day;
}
else if(day=="Sunday" || day=="SUN"){
currentDay = 7;
weekDay[currentDay - 1] = "Sunday";
inputDay = day;
}
else{
cout << "" << endl;
}
}
string dayType::printDay(){
cout << (weekDay + (currentDay-1));
}
string dayType::prevDay(){
cout << (weekDay + (currentDay - 1));
}
void dayType::nextDay(){
switch(currentDay){
case 1:{
currentDay++;
setDay("Tuesday");
break;
}
case 2:{
currentDay++;
setDay("Wednesday");
break;
}
case 3:{
currentDay++;
setDay("Thursday");
break;
}
case 4:{
currentDay++;
setDay("Friday");
break;
}
case 5:{
currentDay++;
setDay("Saturday");
break;
}
case 6:{
currentDay++;
setDay("Sunday");
break;
}
case 7:{
currentDay = 1;
setDay("Monday");
break;
}
}
}
this is my main.
#include <iostream>
#include <string>
#include "dayType.h"
using namespace std;
int main(){
dayType myDay("Monday");
dayType temp("Sunday");
myDay.printDay();
cout << endl;
cout << myDay.prevDay() << endl;
cout << myDay.nextDay() << endl;
temp.printDay();
cout << endl;
cout << temp.prevDay() << endl;
cout << temp.nextDay() << endl;
return 0;
}
i'm pretty lost. =( i know there are lots of errors.