// CSC 442F - Software Engineering
// Calendar Client
// Component: EventId class
// Description: Holds eventid

public class EventId
{
  public String username;
  public String year;
  public String month;
  public String day;
  public String hour;
  public String minute;

  // Constructor 1
  // =============
  public EventId()
  {
    username = new String();
    year = new String();
    month = new String();
    day = new String();
    hour = new String();
    minute = new String();
    }
  
  // Constructor 2
  // =============
  public EventId(String username_in, String year_in, String month_in,
                 String day_in, String hour_in, String minute_in)
  {
    username = new String(username_in);
    year = new String(year_in);
    month = new String(month_in);
    day = new String(day_in);
    hour = new String(hour_in);
    minute = new String(minute_in);
    
    // Note that ranges will not be checked
    // Nor will this class restrict values to strictly integers
    concat();
  }
    

  // Concatenation 1
  // ===============
  // Note that ranges will not be checked
  // Nor will this class restrict values to strictly integers
  public String concat()
  {
    String datetime = new String();

    datetime = datetime.concat(year);
    datetime = datetime.concat("/");
    datetime = datetime.concat(month);
    datetime = datetime.concat("/");
    datetime = datetime.concat(day);
    datetime = datetime.concat("/");
    datetime = datetime.concat(hour);
    datetime = datetime.concat("/");
    datetime = datetime.concat(minute);

    return datetime;
  }
  
  // Concatentation 2
  // ================
  public static String concat(String year_in, String month_in,
                              String day_in, String hour_in, String minute_in)
  // Note that ranges will not be checked
  // Nor will this class restrict values to strictly integers
  // It is assumed that the parameters are strictly integers
  {
    String datetime = new String();
    
    datetime = datetime.concat(year_in);
    datetime = datetime.concat("/");

    // Pad with a zero if necessary
    if (Integer.parseInt(month_in) <10 && month_in.length()==1)
      datetime = datetime.concat("0");
    datetime = datetime.concat(month_in);
    datetime = datetime.concat("/");

    // Pad with a zero if necessary
    if (Integer.parseInt(day_in) <10 && day_in.length()==1)
      datetime = datetime.concat("0");
    datetime = datetime.concat(day_in);
    datetime = datetime.concat("/");

    // Pad with a zero if necessary
    if (Integer.parseInt(hour_in) <10 && hour_in.length()==1)
      datetime = datetime.concat("0");
    datetime = datetime.concat(hour_in);
    datetime = datetime.concat("/");

    // Pad with a zero if necessary
    if (Integer.parseInt(minute_in) <10 && minute_in.length()==1)
      datetime = datetime.concat("0");
    datetime = datetime.concat(minute_in);

    return datetime;
  }
}
