Skip to content

Commit

Permalink
adding question to habit and habit record
Browse files Browse the repository at this point in the history
  • Loading branch information
Rechee committed Jan 6, 2020
1 parent 997ebfc commit 88b9645
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -354,14 +354,26 @@ public void setPosition(int newPosition)
data.position = newPosition;
}

@NonNull
public String getQuestion() {
return data.question;
}

public void setQuestion(@NonNull String question) {
data.question = question;
}

public static final class HabitData
{
@NonNull
public String name;

@NonNull
@Nullable
public String description;

@NonNull
public String question;

@NonNull
public Frequency frequency;

Expand Down Expand Up @@ -390,7 +402,8 @@ public HabitData()
this.frequency = new Frequency(3, 7);
this.type = YES_NO_HABIT;
this.name = "";
this.description = "";
this.description = null;
this.question = "";
this.targetType = AT_LEAST;
this.targetValue = 100;
this.unit = "";
Expand All @@ -401,6 +414,7 @@ public HabitData(@NonNull HabitData model)
{
this.name = model.name;
this.description = model.description;
this.question = model.question;
this.frequency = model.frequency;
this.color = model.color;
this.archived = model.archived;
Expand All @@ -427,6 +441,7 @@ public String toString()
.append("unit", unit)
.append("reminder", reminder)
.append("position", position)
.append("question", question)
.toString();
}

Expand All @@ -451,6 +466,7 @@ public boolean equals(Object o)
.append(unit, habitData.unit)
.append(reminder, habitData.reminder)
.append(position, habitData.position)
.append(question, habitData.question)
.isEquals();
}

Expand All @@ -469,6 +485,7 @@ public int hashCode()
.append(unit)
.append(reminder)
.append(position)
.append(question)
.toHashCode();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public class HabitRecord
@Column
public String description;

@Column
public String question;

@Column
public String name;

Expand Down Expand Up @@ -91,6 +94,7 @@ public void copyFrom(Habit model)
this.targetValue = model.getTargetValue();
this.unit = model.getUnit();
this.position = model.getPosition();
this.question = model.getQuestion();

Frequency freq = model.getFrequency();
this.freqNum = freq.getNumerator();
Expand All @@ -113,6 +117,7 @@ public void copyTo(Habit habit)
habit.setId(this.id);
habit.setName(this.name);
habit.setDescription(this.description);
habit.setQuestion(this.question);
habit.setFrequency(new Frequency(this.freqNum, this.freqDen));
habit.setColor(this.color);
habit.setArchived(this.archived != 0);
Expand Down

0 comments on commit 88b9645

Please sign in to comment.