COSC 111
An Updated Version of the class date

We will add to this!!

public class Date
{
    // the following is called ** INSTANCE DATA *******
    //It should always be declated **private**
    private int day;
    private int month;
    private int year;
   
   
    // The following are referred to as **MUTATORS**
    public void setMonth(int m)
    {
        if ((m<1) || (m>12))   // if m is invalid then set month to 1
           month=1;
        else
           month=m;
       
    }
   
    public void setYear(int y)
    {
        year=y;
       
    }
   
    public void setDay(int d)
    {
        if ((d<1) || (d>31))    // if d is invalid, set the day to 1
            day = 1;
        else
            day = d;
   }
  
   // The following methods are called **ACCESSORS**
   public int getDay()
   {  return(day);}
  
   public int getMonth()
   {  return(month);  }
  
   public int getYear()
   {  return(year);  }
  
   //Here's something new.....a HELPER method. Note it is declared private
   private String getMonthName(int m)
   {
       String temp;
       switch (m)
       {
           case 1:  temp="January";
                    break;
           case 2:  temp="February";
                    break;
           case 3:  temp="March";
                    break;
           case 4:  temp="April";
                    break;
           case 5:  temp="May";
                    break;
           case 6:  temp="June";
                    break;
           case 7:  temp="July";
                    break;
           case 8:  temp="August";
                    break;
           case 9:  temp="September";
                    break;
           case 10: temp="October";
                    break;
           case 11: temp="November";
                    break;
           case 12: temp="December";
                    break;
           default: temp="ERROR";
        }
        return(temp);
    }
   
    // A toString method is required to do output
    public String toString()
    {
        return( this.getMonthName(this.getMonth())+" "+this.getDay()+" , "+this.getYear());
    }
   
    //******* TODO     equals, constructors, overloading
  
   
}