Hello, Please help. Below is my assignment and the code I've got so far. I'm still getting errors on overloading the member function on the printDay and prevDay.

Design and implement a class dayType that implements the day of the week in a program. The class dayType should store the day, such as Sun for Sunday. The program should be able to perform the following operations on an object of type dayType:
-Set the day
-Print the day
-Return the day
-Return the next day
-Return the previous day
-Calculate and return the day by adding certain days to the current day. For example if the current day is Monday and we add 4 days, the day to be returned is Friday. Similarly, if today is Tuesday and we add 13 days, the day to be returned is Monday.
-Add the appropriate constructors.
-Then, write the definitions of the functions to implement the operations for the class dayType as defined in Programming above. Also, write a program to test various operations on this class.

header file

#ifndef DAY_TYPE_H
#define DAY_TYPE_H

#include <iostream>
#include <string>
#include <iomanip>

using namespace std;

/******* Class dayType Specification ********/

class dayType
{
	
	private:
		string days[7];
		string currentDay;
		int numDays;

	public:

		void setDay(string newDay);
		void printDay() const;
		int showDay(int& day);
		int nextDay(int day);
		int prevDay(int day) const;
		int calcDay(int day, int numDays);
				
		dayType()
		{
			days[0] = "Sunday";
			days[1] = "Monday";
			days[2] = "Tuesday";
			days[3] = "Wednesday";
			days[4] = "Thursday";
			days[5] = "Friday";
			days[6] = "Saturday";
			currentDay = days[0];
			numDays = 0;
		};
		~dayType();
	
};


#endif

implementation file

#include "dayType.h"

void dayType::setDay(string newDay)
{
   currentDay = newDay;
}

void dayType::printDay()
{
   cout << "Day chosen is " << currentDay << endl;

}

int dayType::showDay(int& day)
{
   return day;
}

int dayType::nextDay(int day)
{
	day = day++;

	if (day > 6)
		day = day % 7;

	switch (day)
	{
	case 0: cout << "The next day is Sunday";
		break;
	case 1: cout << "The next day is Monday";
		break;
	case 2: cout << "The next day is Tuesday";
		break;
	case 3: cout << "The next day is Wednesday";
		break;
	case 4: cout << "The next day is Thursday";
		break;
	case 5: cout << "The next day is Friday";
		break;
	case 6: cout << "The next day is Saturday";
		break;
	}
	cout << endl;
	return day;
}
	
int dayType::prevDay(int day)
{
	day = day--;

	switch (day)
	{
	case -1: cout << "The previous day is Saturday.";
		break;
	case 0: cout << "The previous day is Saturday.";
		break;
	case 1: cout << "The previous day is Saturday.";
		break;
	case 2: cout << "The previous day is Saturday.";
		break;
	case 3: cout << "The previous day is Saturday.";
		break;
	case 4: cout << "The previous day is Saturday.";
		break;
	case 5: cout << "The previous day is Saturday.";
		break;
	default: cout << "The previous day is Saturday.";
	}

	cout << endl;
	return day;

}

int dayType::calcDay(int addDays, int numDays)
{
	addDays = addDays + numDays;
	if (addDays > 6)
		addDays = addDays % 7;
	switch(addDays)
	{
	case 0: cout << "The calculated day is Sunday.";
		break;
	case 1: cout << "The calculated day is Monday.";
		break;
	case 2: cout << "The calculated day is Tuesday.";
		break;
	case 3: cout << "The calculated day is Wednesday.";
		break;
	case 4: cout << "The calculated day is Thursday.";
		break;
	case 5: cout << "The calculated day is Friday.";
		break;
	case 6: cout << "The calculated day is Saturday.";
		break;
	default: cout << "Not valid choice.";
	}
	cout << endl;
	return addDays;
}

Main

#include <iostream>  
#include <string>  
#include "dayType.h"    

using namespace std;  

void showSelections();

int main()  
{  
	dayType userDay;
	int currentDay; 
	int addDays;
	int test;
	string day;
	

	do
	{
		test = 0;
		showSelections();
		cin >> currentDay;
		cout << endl;

		if (currentDay = 0)
		{
			userDay.setDay("Sunday");
		}
		else if (currentDay = 1)
		{
			userDay.setDay("Monday");
		}
		else if (currentDay = 2)
		{
			userDay.setDay("Tuesday");
		}
		else if (currentDay = 3)
		{
			userDay.setDay("Wednesday");
		}
		else if (currentDay = 4)
		{
			userDay.setDay("Thursday");
		}
		else if (currentDay = 5)
		{
			userDay.setDay("Friday");
		}
		else if (currentDay = 6)
		{
			userDay.setDay("Saturday");
		}
		else if (currentDay = 9)
		{
			cout << "Exiting...";
			return 0;
		}
		else
		{
			cout << "Not a valid choice." << endl;
			test = -37;
		}
	}
	
	while (test < 0);
	userDay.printDay();
	cout << endl;

	userDay.showDay(currentDay);
	cout << endl;
	userDay.nextDay(currentDay);
	cout << endl;
	userDay.prevDay(currentDay);
	cout << endl;

	cout << "Enter the number of days to add: " << endl;
	cin >> addDays;
	cout << endl;

	userDay.calcDay(currentDay, addDays);
	cout << endl;

	cout << endl << endl;
	system("pause");
	return 0;
}
	

// Function to display weekday selections.
void showSelections()
{
	cout << "*****Please enter a day of the week*****" << endl;
	cout << "0 for Sunday" << endl;
	cout << "1 for Monday" << endl;
	cout << "2 for Tuesday" << endl;
	cout << "3 for Wednesday" << endl;
	cout << "4 for Thursday" << endl;
	cout << "5 for Friday" << endl;
	cout << "6 for Saturday" << endl;
	cout << "9 to exit" << endl;


}

I must have missed something. Where is the description of the problem you are having? Is it hidden somewhere? Or are we supposed to read and understand 300 lines of code with no idea what problem we are looking for?

I have better things to do.

Where's my TV remote...?

Much agreed, the format of your post is most unhelpful to us. It's really your responsibility to make sure you meet those requirements, and if you're having trouble or you have a specific question we'll surely help.

if (currentDay = 0)

you want to compare not assign, in another words

if (currentDay == 0)

do that for all of your similar if statements

Thanks firstPerson,
I am still getting these "unresolved token" errors:

dayTypeMain.obj : error LNK2028: unresolved token (0A000419) "public: __thiscall dayType::~dayType(void)" (??1dayType@@$$FQAE@XZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)

and

dayTypeMain.obj : error LNK2019: unresolved external symbol "public: __thiscall dayType::~dayType(void)" (??1dayType@@$$FQAE@XZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)

Is my destructor set-up incorrectly?

You haven't provided an implementation for it.

~dayType();

i ven't got the description of above code . can i get that

#ifndef _daytype_H_  
#define _daytype_H_
# include <iostream>
# include <string>
using namespace std;


class daytype
{
    string Setday(string day);

    void Printday();

    string getday();

    string nextday();

    string preday(); 

    string addday(int numdays);

    daytype();

    daytype(string day);

    private:
        string day;
        string weekday[7];
};

# endif


#include <iostream>
#include "daytype.h"
# include <string>
using namespace std;


string daytype::Setday(string d)
{
   day = d;

return d;
}

string daytype::getday()
{
return day;
}

void daytype::Printday()
{
   cout << day;
}

string daytype::nextday()
{
   int x;
string nxtDay;

for(x = 0; x < 7; x++)

if(day == weekday[x] && day != weekday[6])
nxtDay = weekday[x + 1];
else
nxtDay = weekday[0];

return nxtDay;
}

string daytype::preday()
{
int x;
string prevDay;

for(x = 6; x > 0; x--)
if(day == weekday[x] && day != weekday[0])
prevDay = weekday[x - 1];
else
prevDay = weekday[6];

return prevDay;
}

string daytype::addday(int numDays)
{ 
int newDay;

newDay = numDays % 7;

return weekday[newDay];

}

daytype::daytype() 
{ //Constructor definition
day = "Sun";
weekday[0] = "Sun";
weekday[1] = "Mon";
weekday[2] = "Tue";
weekday[3] = "Wed";
weekday[4] = "Thu";
weekday[5] = "Fri";
weekday[6] = "Sat";
}

I just really need a lil help finishing up the code.
How do you provided an implementation for it?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.