CDate.cc - CDate class definitions Adapted from Hagit Schechter Jan 2007 for 2014W2#include <iostream>#include <string>#include\"CDate.h

CDate.cc - CDate class definitions Adapted from Hagit...

This preview shows page 1 - 2 out of 3 pages.

// .................................................. // CDate class definitions // Adapted from Hagit Schechter, Jan 2007 for 2014W2 // .................................................. #include <iostream> #include <string> #include "CDate.h" CDate::CDate(void){ m_year = m_month = m_day = 0; } CDate::CDate(int year, int month, int day){ setDate( year, month, day ); } CDate::CDate(int year, std::string month, int day){ setDate( year, monthStr2Num(month), day); // TODO you need to fill in the code here ******** // HINT use monthStr2Num to get the month_num } bool CDate::isValidDate(int year, int month, int day){ if (year < 0 || month < 0 || month > 12 || !isValidDay(year, month, day)) { return false; } else { return true; } // TODO you need to fill in the code here ******** // comment out the "return false" below // then check the validity of a year, month, and day } bool CDate::isValidDate(int year, std::string month, int day){ if (year < 0 || monthStr2Num(month) < 0 || monthStr2Num(month) > 12 || ! isValidDay(year, monthStr2Num(month), day)) { return false; } else { return true; } // TODO you need to fill in the code here ******** // comment out "return false" below // HINT use monthStr2Num to get the month_num // and then reuse another function } int CDate::monthStr2Num(std::string month){ if (month.compare("January") == 0){
Image of page 1
Image of page 2

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture