package seedu.jimi.model.task;

import seedu.jimi.commons.util.CollectionUtil;
import seedu.jimi.model.tag.UniqueTagList;

import java.util.Objects;

/**
 * Represents a task in the task book.
 * Guarantees: details are present and not null, field values are validated.
 */
public class FloatingTask implements ReadOnlyTask {

    private Name name;
    private UniqueTagList tags;
    private boolean isCompleted;

    public FloatingTask(Name name, UniqueTagList tags, boolean isCompleted) {
        this(name, tags);
        this.isCompleted = isCompleted;
    }
    
    /**
     * Every field must be present and not null.
     */
    public FloatingTask(Name name, UniqueTagList tags) {
        assert !CollectionUtil.isAnyNull(name, tags);
        this.isCompleted = false;
        this.name = name;
        this.tags = new UniqueTagList(tags); // protect internal tags from changes in the arg list
    }

    /**
     * Copy constructor.
     */
    public FloatingTask(ReadOnlyTask source) {
        this(source.getName(), source.getTags(), source.isCompleted());
    }
    

    @Override
    public Name getName() {
        return name;
    }

    @Override
    public UniqueTagList getTags() {
        return new UniqueTagList(tags);
    }

    /**
     * Replaces this floating task's name with name provided.
     * @param name Name to be replaced by.
     */
    public void setName(Name name){
        this.name = name;
    }
    
    public void setTags(UniqueTagList replacement) {
        tags.setTags(replacement);
    }
    
    /**
     * Set the task to be completed/incomplete.
     * @param isCompleted is true if task is completed.
     */
    public void setCompleted(boolean isCompleted) {
        this.isCompleted = isCompleted;
    }
    
    @Override
    public boolean equals(Object other) {
        return other == this // short circuit if same object
                || (other instanceof ReadOnlyTask // instanceof handles nulls
                && this.isSameStateAs((ReadOnlyTask) other));
    }
    
    @Override
    public boolean isSameStateAs(ReadOnlyTask other) {
        return other == this // short circuit if same object
                || (other instanceof FloatingTask // instanceof handles nulls
                && (other).getName().equals(this.getName()) // state checks here onwards
                && (other).isCompleted() == this.isCompleted()
                );
    }

    @Override
    public int hashCode() {
        // use this method for custom fields hashing instead of implementing your own
        return Objects.hash(name, tags);
    }

    @Override
    public String toString() {
        return getAsText();
    }
    
    @Override
    public String getAsText() {
        final StringBuilder builder = new StringBuilder();
        builder.append(getName())
               .append(" Tags: ");
        getTags().forEach(builder::append);
        return builder.toString();
    }

    @Override
    public boolean isCompleted() {
        return isCompleted;
    }

}
@@ -72,16 +72,54 @@
 onUtil;%0A
+import seedu.jimi.model.tag.Priority;%0A
 import s
@@ -445,16 +445,47 @@
 mpleted;
+%0A    private Priority priority;
 %0A%0A    pu
@@ -544,32 +544,51 @@
 lean isCompleted
+, Priority priority
 ) %7B%0A        this
@@ -590,32 +590,42 @@
  this(name, tags
+, priority
 );%0A        this.
@@ -780,16 +780,35 @@
 ist tags
+, Priority priority
 ) %7B%0A    
@@ -1016,16 +1016,50 @@
 rg list%0A
+        this.priority = priority;%0A
     %7D%0A%0A 
@@ -1214,16 +1214,38 @@
 pleted()
+, source.getPriority()
 );%0A    %7D
@@ -1413,24 +1413,110 @@
 tags);%0A    %7D
+%0A    %0A    @Override%0A    public Priority getPriority() %7B%0A        return priority;%0A    %7D
 %0A%0A    /**%0A  
@@ -2013,32 +2013,127 @@
 ted;%0A    %7D%0A    %0A
+    public void setPriority(Priority priority)  %7B%0A        this.priority = priority;%0A    %7D%0A    %0A
     @Override%0A  
@@ -3248,16 +3248,93 @@
 ppend);%0A
+        builder.append(%22 Priority: %22)%0A               .append(getPriority());%0A
         

Implement Priority in FloatingTask