I need to write a date class program

I need to write a date class program that checks for a string month, int day, and int year. I have tried many ways to write the program but i cant figure it out. Also, i need to output the date instance four different times like in these formats....1/1/2001 January 1, 2001 2001-1-1 2001-jan-1, that should be used in a seperate print member function.

//header file
#include <string>

enum DateFormat {mdy1, mdy2, ymd3, ymd4};
int MIN_YEAR = 1900;
int MAX_YEAR = 2020;
const string monthStr[] = { "January", "Febuary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
const string monthStrAbbrev[] = { "jan", "feb", "mar", "apr", "may", "jun","jul", "aug", "sep", "oct", "nov","dec" };
const int monthDays[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

class Date
{
private:
string month;
int day;
int year;
bool isMonthValid(string m);
bool isDayValid(int dy);
bool isYearValid(int yr);
public:
Date(string m, int d, int y);

};

//date.cpp file
#include "Date.h"
#include <string>
#include <iostream>

using namespace std;

Date::Date(string m, int d, int y)
{
month = m;
day = d;
year = y;
}

bool Date::isMonthValid(string m)
{


}

bool Date::isDayValid(int d)
{
for (int i = 0; i < 11; i++)
{
if (d > monthDays[i])
return false;
else
return monthDays[i];
}
}

bool Date::isYearValid(int y)
{
if (y < MIN_YEAR || y > MAX_YEAR)
return false;
else
return true;
}

//test.cpp file
#include <iostream>
#include "Date.h"
#include <string>

using namespace std;

void setDateValues(string&, int&, int&);

int main()
{
string month;
int day, yr;

setDateValues(month, day, yr);
Date date(month, day, yr);
cout << "Date is: \n";


}

void setDateValues(string &m, int &d, int &y)
{
cout << "Enter month: ";
cin >> m;
cout << "Enter day: ";
cin >> d;
cout << "Enter year: ";
cin >> y;
}
That doesn't sound quite right. What's the exact wording of your assignment?
I need to write a program that outputs the date the user inputs. I need to write the class header file which has three private member variables, string month, int day, int year. I need to write private member functions to check whether the string month array is one of the months the user has input and then a public member function that checks the private member functions. Also, i need to display the the date in four formats using the enum.
I see. Are stuck on isMonthValid()?
Topic archived. No new replies allowed.