package com.example.model;

import java.util.*;
import java.lang.*;

/**
 * The TimeUnit class contains the data members and functionality
 * necessary to assemble and retrieve a time constraint.  The time
 * constraint consists of a day (i.e.: M,T,W,R,F,S,U) and a time
 * (i.e.: 11:45, 13:00, etc).  A time is composed of an hour and
 * minute value stored in military time to avoid confusion or
 * possible overlap.
 *
 * @author Matthew Arbaugh, Tara Strobel
 * @version A10
 */
public class TimeUnit {

  /**
   * Day of the week for the entry. (M,T,W,R,F,S,U)
   */
  private int day;

  /**
   * Hour component of entry. Stored in military time. (0-23)
   */
  private int startHour;
  private int endHour;

  /**
   * Minute component of entry. (0-59)
   */
  private int startMinute;
  private int endMinute;

  /**
   * Default constructor for TimeUnit sets the day value to M,
   * the hour value to 0, and the minute value to 0.
   */
  public TimeUnit() {
	day = 0;
	startHour = 0;
	endHour = 0;
	startMinute = 0;
	endMinute = 0;
  }

  /**
   * Overloaded constructor for TimeUnit sets all data values to user
   * input.
   *
   * @param d Value of day as input by user. (M,T,W,R,F,S,U)
   * @param h Value of hour as input by user. (0-23)
   * @param m Value of minute as input by user. (0-59)
   */
  public TimeUnit(int d, int sh, int sm, int eh, int em) {
	day = d;
	startHour = sh;
	startMinute = sm;	
	endHour = eh;
	endMinute = em;
  }
    
    /**
     * Sets the day, hour, and minute values of the TimeUnit.
     *
     * @param d Value of day as input by user. (M,T,W,R,F,S,U)
     * @param h Value of hour as input by user. (0-23)
     * @param m Value of minute as input by user. (0-59)
     */
    public void setTimeUnit(int d, int sh, int sm, int eh, int em) {
	day = d;
	startHour = sh;
	startMinute = sm;	
	endHour = eh;
	endMinute = em;
    }
    
    /**
     * Returns the day value of the TimeUnit.
     *
     * @return char 
     */
    public int getDay() {
	return day;
    }
    
    /**
     * Returns the hour value of the TimeUnit.
     *
     * @return int 
     */
    public int getStartHour() {
	return startHour;
    }

    /**
     * Returns the minute value of the TimeUnit.
     *
     * @return int 
     */
    public int getStartMinutes() {
	return startMinute;
    }

    /**
     * Returns the hour value of the TimeUnit.
     *
     * @return int 
     */
    public int getEndHour() {
	return endHour;
    }
    
    /**
     * Returns the minute value of the TimeUnit.
     *
     * @return int 
     */
    public int getEndMinutes() {
	return endMinute;
    }
    
    //overloaded toString
    public String toString()
    {
	String d = "";
        switch(day) {
	case 0: d="Sun"; break;
	case 1: d="Mon"; break;
	case 2: d="Tue"; break;
	case 3: d="Wed"; break;
	case 4: d="Thu"; break;
	case 5: d="Fri"; break;	  
	case 6: d="Sat"; break;
	}
	String str = new String();
	str = d + ": " + startHour + ":";
	if(startMinute < 10)
		str += "0"+startMinute;
	else
		str += startMinute;
	str +="-"+endHour+":";
	if(endMinute < 10)
		str += "0"+endMinute;
	else
		str += endMinute;
	return str;  
    }


}
