package com.example.avjindersinghsekhon.minimaltodo;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.UUID;

public class ToDoItem implements Serializable{
    private String mToDoText;
    private int mTodoColor;
    private UUID mTodoIdentifier;
    private static final String TODOTEXT = "todotext";
    private static final String TODOCOLOR = "todocolor";
    private static final String TODOIDENTIFIER = "todoidentifier";


    public ToDoItem(String todoBody){
        mToDoText = todoBody;
        mTodoColor = 1677725;
        mTodoIdentifier = UUID.randomUUID();
    }

    public ToDoItem(JSONObject jsonObject) throws JSONException{
        mToDoText = jsonObject.getString(TODOTEXT);
        mTodoColor = jsonObject.getInt(TODOCOLOR);
        mTodoIdentifier = UUID.fromString(jsonObject.getString(TODOIDENTIFIER));
    }

    public JSONObject toJSON() throws JSONException{
        JSONObject jsonObject = new JSONObject();
        jsonObject.put(TODOTEXT, mToDoText);
        jsonObject.put(TODOCOLOR, mTodoColor);
        jsonObject.put(TODOIDENTIFIER, mTodoIdentifier.toString());
        return jsonObject;
    }


    public ToDoItem(){
        this("Clean my room");
    }

    public String getToDoText() {
        return mToDoText;
    }

    public void setToDoText(String mToDoText) {
        this.mToDoText = mToDoText;
    }

    public int getTodoColor() {
        return mTodoColor;
    }

    public void setTodoColor(int mTodoColor) {
        this.mTodoColor = mTodoColor;
    }

    public UUID getIdentifier(){
        return mTodoIdentifier;
    }

    /** Check equal ID and todo text. */
    public boolean equals(Object obj) {
        if (obj instanceof ToDoItem) {
            ToDoItem item = (ToDoItem) obj;
            return item.getIdentifier().equals(this.getIdentifier()) &&
                item.getToDoText().equals(this.getToDoText());
        }
        return false;
    }
}


@@ -479,16 +479,74 @@
 fier%22;%0A%0A
+    public static String DEFAULT_TEXT = %22Clean my room%22;%0A%0A
 %0A    pub
@@ -1241,17 +1241,16 @@
 %0A    %7D%0A%0A
-%0A
     publ
@@ -1277,31 +1277,28 @@
    this(
-%22Clean my room%22
+DEFAULT_TEXT
 );%0A    %7D
@@ -1449,32 +1449,117 @@
 oDoText;%0A    %7D%0A%0A
+    public boolean hasToDoText() %7B%0A        return getToDoText().length() %3E 0;%0A    %7D%0A%0A
     public int g
@@ -2081,16 +2081,16 @@
       %7D%0A
-
         
@@ -2108,12 +2108,147 @@
 e;%0A    %7D
+%0A%0A    /** The normal string representation of an item is its text */%0A    public String toString() %7B%0A        return getToDoText();%0A    %7D
 %0A%7D%0A%0A

Add toString() and hasToDoText() methods, and store the default text in a variable.