package com.cmput301f17t11.cupofjava;

import java.util.ArrayList;
import java.util.Date;

/**
 * This class handles all properties related to a habit.
 * A habit contains a title, reason, date, frequency.
 * User can find out if habit is followed by another
 * user or not.
 */
public class Habit {

    private String habitTitle; //TODO: ensure habitTitle no more than 20 chars
    private String habitReason; //TODO: ensure habitReason no more than 30 chars
    private Date habitStartDate;
    private ArrayList<Integer> repeatingDays; //0 = Sun, 1 = Mon... 6 = Sat
    private int habitStatus = 0; //how closely the habit is being followed on a scale of 1 to 10.
                                 //for each day folloed, +1 and missing days would result in -1

    /**
     * Constructor for Habit class.
     * @param title
     * @param reason
     * @param date
     */
    public Habit(String title, String reason, Date date){
        this.habitTitle = title;
        this.habitReason = reason;
        this.habitStartDate = date;
    }

    public String getHabitTitle() {
        return habitTitle;
    }

    public void setHabitTitle(String habitTitle) {
        this.habitTitle = habitTitle;
    }

    public String getHabitReason() {
        return habitReason;
    }

    public void setHabitReason(String habitReason) {
        this.habitReason = habitReason;
    }

    public Date getHabitStartDate() {
        return habitStartDate;
    }

    public void setHabitStartDate(Date habitStartDate) {
        this.habitStartDate = habitStartDate;
    }

    /**
     * A controller class will use these methods to keep track of how closely the habits are followed
     */

    public void habitFollowed(){
        this.habitStatus++;
        if (this.habitStatus < 0){
            this.habitStatus = 0;
        }
    }

    public void habitNotFollowed(){
        this.habitStatus--;
        if (this.habitStatus > 10){
            this.habitStatus = 10;
        }
    }

    public int getHabitStatus(){
        return habitStatus;
    }
}

@@ -328,137 +328,40 @@
 tle;
- //TODO: ensure habitTitle no more than 20 chars%0A    private String habitReason; //TODO: ensure habitReason no more than 30 chars
+%0A    private String habitReason;
 %0A   
@@ -1059,24 +1059,155 @@
 bitTitle) %7B%0A
+        if (habitTitle.length() %3E 20)%7B%0A            new Exception(%22Habit Title longer than 20 chars%22);%0A        %7D%0A        else %7B%0A    
         this
@@ -1224,32 +1224,42 @@
 e = habitTitle;%0A
+        %7D%0A
     %7D%0A%0A    publi
@@ -1370,24 +1370,157 @@
 itReason) %7B%0A
+        if (habitReason.length() %3E 30)%7B%0A            new Exception(%22Habit Reason longer than 30 chars%22);%0A        %7D%0A        else %7B%0A    
         this
@@ -1539,32 +1539,42 @@
  = habitReason;%0A
+        %7D%0A
     %7D%0A%0A    publi

Check length of habit title and reason