/* ++[ Machine Problem #2 ]++++++++++++++++++++++++++++++++++++++
   +								+
   + Zaczek, Mariusz						+
   + CS 223 - Monday 11:00am - 1:00 pm				+
   + 2/22/98							+
   + 								+
   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */

/* ++[  main  ]++++++++++++++++++++++++++++++++++++++++++++++++++
   + Function: main()                                           +
   +                                                            +
   +   Takes: no values						+
   +                                                            +
   +   Returns: no values					+
   +                                                            +
   +   Actions: Prompts user to input a date. It then check     +
   +            if the date is valid. If it is then the user is +
   + 		prompted to enter the number of days to 	+
   +		increment the current date. The program then    +
   +            outputs the new date.				+
   +                                                            +
   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */

/* Include declarations */
#include <iostream.h>
#include <string.h>
#include <ctype.h>
#include "date.h"

/* Beginning of main body of code */
int main()
{
  /* Declare variable date1 of Class Date as well as the month,
     day, year and number variables */
  Date date1;
  char month[4]; 
  int day, year, number;
  
  /* Prompt user to enter a date in Month Day Year form */
  cout << "Enter the date:" << endl;
  cin >> month >> day >> year;

  if (strlen(month) > 3)
  { 
    cout << "Invalid Date" << endl;
    return 0;
  }

  /* Change the cases of the letter of the month entered.
     The format should have the first letter be capital and the 
     rest be lower case */
    month[0] = toupper(month[0]);
    month[1] = tolower(month[1]);
    month[2] = tolower(month[2]);
    
  /* Set the date to class variable date1 */
  date1.setDate(month, day, year); 

  /* Determine if the date entered is valid. If so then contiue on
     otherwise exit displaying an error message */
  if (date1.isValid()==1)
  { 
    cout << "Enter the number of days to add:" << endl;
    cin >> number;

    if (number < 0)
      number=0;
	 
    date1.addDays(number);

    date1.printDate();
  }
  else
  {
    cout << "Invalid Date" << endl;
    return -1;
  }

return 0;
}



