import java.util.ArrayList;
/**
 * Assignment store the information for a course assignment.
 *
 * @author Fred Kral
 * @version 1.3
 *
 */
  /* Change Log
     Fred Kral    1.2   1/19/2015   Move raw data parsing & interpretation to readAssignments2.java.
     Emma Neary   1.3               Assignment name get method.
 */
public class Assignment {

   String rawData = "";
   plainDate pDate;
   Course course;
   boolean activeAssignment = true;
   String assignmentName = "";
   String shortAssignmentName = "";
   String type = "";
   String description = "";
   String files = "";
   String value = "";
   String result = "";
   String comment = "";
   String upload = "";
   
   
   /** 
     Assignments in a course live here. This is independent of the raw data file format.
     @param rawData is the unchanged or mended String from the input file
     @param pDate holds the date information
     @param course holds the course information for the person
     Everything else as listed in the parameter list is based on the raw data format. 
   */
   public Assignment(String rawData, plainDate pDate, Course course,
                     String assignmentName,
                     String type,
                     String description,
                     String files,
                     String value,
                     String result,
                     String comment,
                     String upload) {
                     
      this.rawData = rawData;
      this.pDate = pDate;
      this.course = course;
      this.assignmentName = assignmentName;
      this.type = type;
      this.description = description;
      this.files = files;
      this.value = value;
      this.result = result;
      this.comment = comment;
      this.upload = upload;
      
            
      // short name
      int maxLength = 20;
      if (assignmentName.length() >= maxLength) {
         shortAssignmentName = assignmentName.substring(0,maxLength);
      }
      else {  // pad on the right
         shortAssignmentName = assignmentName.format("%1$-"+ maxLength +"s", assignmentName);
      }
   }
   public boolean getActiveAssignment() {
      return activeAssignment;
   }
   
   public plainDate getPlainDate () {
      return pDate;
   } 
   
   public Course getCourse () {
      return course;
   }
   
   public String getShortAssignmentName() {
      return shortAssignmentName;
   }   
   
   // EN: Add full assignment name
   public String getAssignmentName() {
      return assignmentName;
   }
   
   public String getValue() {
      return value;
   }
   
   public String getResult() {
      return result;
   }
   
   
   
   public void sysPrint () {
      if (activeAssignment && course.getActive() )
         System.out.printf("%s : %s %s %s\n", 
            pDate.sysPrint(false), 
            course.getNickName(), 
            course.getCourseBlock(), 
            assignmentName);
   }
   
   public void sysPrintAll () {
      if (activeAssignment && course.getActive() )
         System.out.printf("%s : %s  %s  %s  %s D:  %s F:  %s V=%s  R=%s  C: %s  U: %s\n", 
            pDate.sysPrint(false), 
            course.getNickName(), 
            course.getCourseBlock(), 
            assignmentName, type, description, files,
            value, result, comment, upload
            );
   
   }
   
   
   public void sysPrintValue () {
      
      if (activeAssignment && course.getActive() )
         System.out.printf("%s : %s  %s  \t V=%s \t\t\t  R=%s\n", 
            pDate.sysPrint(false), 
            course.getNickName(),  
            shortAssignmentName,
            //assignmentName.substring(0,1),
            value, 
            result
            );
   
   }
   
   public void sysPrintRaw () {
      if (activeAssignment)
         System.out.printf("%s : %s\n", pDate.sysPrint(false), rawData);
   }

}// END class