//The Sluggy data class for use with the Sluggy Class
//See the Sluggy Class file for more info.
//date takes the form of yymmdd? I think

import java.util.*;

public class SluggyDate
{
  //Data
  int year;
  int month;
  int day;

  //construtors
  SluggyDate()
  {
    day = 0;
    month = 0;
    year = 0;
  }

  SluggyDate(int year, int month, int day)
  {
    this.day = day;
    this.month = month;
    this.year = year;   
  }

  public boolean equals(SluggyDate sd)
  {
    if( (sd.year == this.year) && (sd.month == this.month) &&
        (sd.day == this.day) )
      return true;
    else
      return false;
  }
 
  public String toString()
  {

    StringBuffer date = new StringBuffer();
    int tmpyear = year%100;
    if( tmpyear < 10 )
    {
      date.append(0);
      date.append(tmpyear);
    }
    else
      date.append(tmpyear);
    
    if( month < 10 )
    {
      date.append(0);
      date.append(month);
    }
    else
      date.append(month);

    if( day < 10 )
    {
      date.append(0);
      date.append(day);
    }
    else
      date.append(day);

    return date.toString();
  }

  public void Tomorrow()
  {
    if(is31day())
      day = (day + 1)%32;
    else if(February())
      day = (day + 1)%29;  //I'll get the leap years myself
    else 
      day = (day + 1)%31;

    if(day == 0)
    {
      day = 1;
      month = (month + 1) % 13;
      if(month == 0)
      {
        month = 1;
        year = (year + 1)%100;
      }
    }
      
  }

  private boolean February()
  {
    if(month == 2)
      return true;
    else
      return false;
  }

  private boolean is31day()
  {
    if(month < 8)
      if ( month % 2 != 0 )
        return true;
      else
        return false;
    else
      if ( month % 2 != 0 )
        return false;
      else
        return true;
  }

  public boolean isSunday()
  //This function was adapted from a C function.
  // I wasn't smart enought to write it
  {
    int tmpyear = year;
    final int[] t = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
    if(month < 3)
      tmpyear--;
    int result = (tmpyear + tmpyear/4 - tmpyear/100 + tmpyear/400 + t[month-1] + day) % 7;
    if(result == 0) //it is sunday
      return true;
    else 
      return false;
  }
    


  public static void main(String args[])
  {
    //test harness
    SluggyDate sd = new SluggyDate(1999,4,27);
    for(int i=0; i<8; i++)
    {
      System.out.println(sd.toString());
      sd.Tomorrow();
    }
  }

}
