Skip to content

Commit

Permalink
src/main/java/task/FixedTask.java: Add javadoc.
Browse files Browse the repository at this point in the history
  • Loading branch information
Exprescode committed Sep 15, 2019
1 parent 23a0996 commit 6566fc2
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/main/java/task/FixedTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
public class FixedTask extends Task {
int durationHour, durationMinute;

/**
* Creates FixedTask object that represents a fixed duration task.
* @param desc Task description.
* @param check Mark task as done.
* @param durationHour Duration require to complete task. (Hours)
* @param durationMinute Duration require to complete task. (Minutes)
* @throws DukeException
*/
public FixedTask(String desc, boolean check, int durationHour, int durationMinute) throws DukeException {
super(desc, check);
checkHour(durationHour);
Expand All @@ -13,12 +21,22 @@ public FixedTask(String desc, boolean check, int durationHour, int durationMinut
this.durationMinute = durationMinute;
}

/**
* Checks for valid hour representation.
* @param hour Integer hour to validate.
* @throws DukeException Hour is not a positive neutral number.
*/
private void checkHour(int hour) throws DukeException {
if (hour < 0) {
throw new DukeException("FixedTask argument hour must be a positive neutral number.");
}
}

/**
* Checks for valid minute representation.
* @param minute Integer minute to validate.
* @throws DukeException Minute is not a positive neutral number less than 60.
*/
private void checkMinute(int minute) throws DukeException {
if (minute >= 60) {
throw new DukeException("FixedTask argument minute can be simplified to hours.");
Expand All @@ -28,6 +46,10 @@ private void checkMinute(int minute) throws DukeException {
}
}

/**
* Formats object variables to text form.
* @return Printable text representation of object.
*/
public String toString() {
String printHour = durationHour > 0 ? durationHour + " Hour" + (durationHour > 1 ? "s" : "") : "";
String printMinute = durationMinute > 0 ? durationMinute + " Minute" + (durationMinute > 1 ? "s" : "" ) : "";
Expand Down

0 comments on commit 6566fc2

Please sign in to comment.