// File: dayofyear_v3.cpp
// Implements the version 3 DayOfYear class member functions

#include <iostream>
#include "dayofyear_v3.h"
using namespace std;

// Default constructor
// Initializes the date to January first.
DayOfYear::DayOfYear( )
{
    myMonth = 1;
    myDay = 1;
}  // end default constructor

// Explicit-value constructor
// Precondition: theMonth and theDay form a possible date.
// Initializes the date according to the arguments.
DayOfYear::DayOfYear(int theMonth, int theDay)
{
    myMonth = theMonth;
    myDay = theDay;
}  // end explicit value constructor

// Function: Month
// Returns the month, 1 for January, 2 for February, etc.
int DayOfYear::Month( ) const
{
    return myMonth;
}  // end Month

// Function: Day
// Returns the day of the month.
int DayOfYear::Day( ) const
{
    return myDay;
}  // end Day

// Function: operator==
// Returns true if date1 is same day of year as date2,
// false otherwise
bool operator==(const DayOfYear & date1, const DayOfYear & date2)
{
     return ( date1.myMonth == date2.myMonth &&
                date1.myDay == date2.myDay );
}  // end operator==

// Function: Input
// Precondition: the input values will form a valid combination
// Reads a DayOfYear value in mm/dd format from an input stream
void DayOfYear::Input(istream & in)
{
   char dummy;
   in >> myMonth;
   in >> dummy;  // the slash separator
   in >> myDay;
}  // end Input

// Function: Output
// Displays a DayOfYear value in mm/dd format on an output stream
void DayOfYear::Output(ostream & out ) const
{
   out << myMonth << '/' << myDay;
}  // end Output
