Programming Diploma in Assembler, Fortran, Basic

Also studied at Computer Learning Center C++, JavaScript,HTML, Visual Basic 6.0

//Michael Wetherwax
//Date Class implementaion - C++
#include
#include
#include
#include
#include
#include
#include "Date.h"
#include"Person.h"

const int Date::monthDays[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

Date::Date() //:month(0),day(0),year(0) {}
Date::~Date() {}

void Date::getDate()
{
Date tday;
char buffer3[3];
char buffer4[3];
char buffer5[5];
int answer = 0;
// int mo, da, yr, thisyear; do { cout<<"\nEnter month number : "; cin<<buffer3; answer = isValidbmoDigit(buffer3); if (answer == 1) strcpy (m, buffer3); mo = atoi(m); cout<<"Mo = "<<mo; }
while((answer == 0) || ((mo > 12) || (mo < 1))); answer = 0;
do
{
cout<<"\nEnter day number : ";
cin<<buffer4;
answer = isValidbdayDigit(buffer4);
if (answer == 1)
strcpy (d, buffer4);

da = atoi(d);
cout<<"Da = "<<da;
}
while((answer == 0) || ((da > 31) || (da < 1)));
answer = 0;

do
{
cout<<"\nEnter year number(xxxx) : ";
cin<<buffer5;
answer = isValidbyearDigit(buffer5);
if (answer == 1)
{
strcpy (y, buffer5);
}
yr = atoi(y);
cout<<"yr = "<<yr;
tday = tday.callToday();
thisyear = tday.printYear();
if (yr > thisyear)
{
cout<<"\nInvalid year!";
}
}
while ((answer == 0) || (yr > thisyear));
}

int Date::isValidbmoDigit(char numb[] )
{
int digit3 = 0;
int nondigit3 = 0;
for (unsigned j = 0; j < strlen(numb); j++) {
if (isdigit(numb[j]))
digit3++;
if (! isdigit(numb[j]))
nondigit3++;
}
if ((nondigit3 > 0)||(digit3 >2))
{
cout<<"Month must be no more than 2 numbers. Enter again!\n"; return 0;
}
else return 1; }

int Date::isValidbdayDigit(char numb[] )
{
int digit4 = 0;
int nondigit4 = 0;
for (unsigned j = 0; j < strlen(numb); j++)
{
if (isdigit(numb[j]))
digit4++;
if (! isdigit(numb[j]))
nondigit4++;
}
if ((nondigit4 > 0)||(digit4 > 2))
{
cout<<"Day must be no more than 2 . Enter again!\n";
return 0;
}
else
return 1;
}

int Date::isValidbyearDigit(char numb[] )
{
int digit5 = 0;
int nondigit5 = 0;
for (unsigned j = 0; j < strlen(numb); j++)
{
if (isdigit(numb[j]))
digit5++;
if (! isdigit(numb[j]))
nondigit5++;
}
if ((nondigit5 > 0)||(digit5 != 4))
{ cout<<"Year must be 4 numbers. Enter again!\n";
return 0;
}
else
return 1;
}
void Date::printDate()
{ cout <<mo << "/" <<da<< "/ " <<yr<<"\n"; }