import java.util.List;
import java.util.ArrayList;
/**
 * Course stores the info for one course
 *
 * @author Fred Kral
 * @version 1.1
 *
 *
 */
public class Course {
   
   String name = "";
   String nickName = ""; // short name of a course
   String courseTitle = "";
   String courseBlock = "";
   boolean active = true;
   
   private final List<Assignment> assignments;  
   
   public Course () {
      this("A Course Goes Here, X");
   }
   
   public Course (String name) {
      this.name = name;
      String[] parts = name.split(", ");
      
      // Advisory is not an active course
      active = name.indexOf("Advisory") < 0 && name.indexOf("Recording") < 0;
      courseTitle = parts[0];
      courseBlock = parts[1];
      String cTitle = courseTitle;
      // length of nickname
      int sub = 8;
      // pad short course names
      if (cTitle.length() < sub) {
         for (int i = cTitle.length()-1; i < sub; i++) {
            cTitle = cTitle + " ";
         }
      }
      
      nickName = cTitle.substring(0, sub-1);
      
      
      this.assignments = new ArrayList<Assignment>();
   
   }
   
   public void addAssignment (Assignment assignment) {
      assignments.add(assignment);
   
   }
   public boolean getActive() {
      return active;
   }
   public String getName() {
      return name;
   }
   public String getCourseTitle() {
      return courseTitle;
   }
   public String getCourseBlock() {
      return courseBlock;
   }
   public String getNickName() {
      return nickName;
   }
   
   public List<Assignment> getAssignments () {
      return assignments;
   }
   
   public boolean equals(String nameIn){
      return name.equals(nameIn);
   }
   
   public boolean equals(Course courseIn) {
      return equals( courseIn.getName() );
   }
   
   public void sysPrint () {
      System.out.print (name);
      if (nickName.equals("")) 
         System.out.println();
      else 
         System.out.println(" " + nickName);
   }


   public void sysPrintAssignments () {
      for (Assignment assignment : assignments) {
         assignment.sysPrintValue();
      }
   }
   
   public void sysPrintAssignmentsAll () {
      for (Assignment assignment : assignments) {
         assignment.sysPrintAll();
      }
   }
   public void sysPrintAssignmentsRaw () {
      for (Assignment assignment : assignments) {
         assignment.sysPrintRaw();
      }
   }
   
   
} // END class