Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create 3 child class to parent class, task class #8

Merged
merged 6 commits into from
Oct 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ Format: `sort CATEGORY`

Example:<br>
* `sort A`
* `Sort D`
* `sort D`

#### Reserving a time slot : `reserve`
Reserves a time slot and prevents you from scheduling conflicting tasks.<br>
Expand Down Expand Up @@ -192,7 +192,7 @@ Exits the program.<br>
Format: `exit`

#### Saving the data
Address book data are saved in the hard disk automatically after any command that changes the data.<br>
Task Manager data are saved in the hard disk automatically after any command that changes the data.<br>
There is no need to save manually.

## Command Cheatsheet
Expand All @@ -206,7 +206,7 @@ Search | `search KEYWORD`
Reserve | `reserve DATE, TIME`
Edit | `edit INDEX FIELD NEW_INFORMATION`
List | `list DATE`
Undo | `Uno`
Undo | `undo`
Sort | `sort CATEGORY`
Help | `help`
Exit | `exit`
89 changes: 89 additions & 0 deletions src/main/java/seedu/ggist/model/task/DeadlineTask.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package seedu.ggist.model.task;

import java.util.Objects;

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

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

private TaskName taskName;
private Date date;
private Time startTime;
private Time endTime;

private UniqueTagList tags;

/**
* Every field must be present and not null.
*/
public DeadlineTask(TaskName taskName, Date date, Time endTime, UniqueTagList tags) {
this.taskName = taskName;
this.date = date;
this.startTime = null;
this.endTime = endTime;
this.tags = new UniqueTagList(tags); // protect internal tags from changes in the arg list
}

/**
* Copy constructor.
*/
public DeadlineTask(ReadOnlyTask source) {
this(source.getTaskName(), source.getDate(), source.getEndTime(), source.getTags());
}

@Override
public TaskName getTaskName() {
return taskName;
}

@Override
public Date getDate() {
return date;
}

@Override
public Time getStartTime() {
return startTime;
}

@Override
public Time getEndTime() {
return endTime;
}

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

/**
* Replaces this person's tags with the tags in the argument tag list.
*/
public void setTags(UniqueTagList replacement) {
tags.setTags(replacement);
}

@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 int hashCode() {
// use this method for custom fields hashing instead of implementing your own
return Objects.hash(taskName, date, startTime, endTime, tags);
}

@Override
public String toString() {
return getAsText();
}

}
89 changes: 89 additions & 0 deletions src/main/java/seedu/ggist/model/task/EventTask.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package seedu.ggist.model.task;

import java.util.Objects;

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

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

private TaskName taskName;
private Date date;
private Time startTime;
private Time endTime;

private UniqueTagList tags;

/**
* Every field must be present and not null.
*/
public EventTask(TaskName taskName, Date date, Time startTime, Time endTime, UniqueTagList tags) {
this.taskName = taskName;
this.date = date;
this.startTime = startTime;
this.endTime = endTime;
this.tags = new UniqueTagList(tags); // protect internal tags from changes in the arg list
}

/**
* Copy constructor.
*/
public EventTask(ReadOnlyTask source) {
this(source.getTaskName(), source.getDate(), source.getStartTime(), source.getEndTime(), source.getTags());
}

@Override
public TaskName getTaskName() {
return taskName;
}

@Override
public Date getDate() {
return date;
}

@Override
public Time getStartTime() {
return startTime;
}

@Override
public Time getEndTime() {
return endTime;
}

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

/**
* Replaces this person's tags with the tags in the argument tag list.
*/
public void setTags(UniqueTagList replacement) {
tags.setTags(replacement);
}

@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 int hashCode() {
// use this method for custom fields hashing instead of implementing your own
return Objects.hash(taskName, date, startTime, endTime, tags);
}

@Override
public String toString() {
return getAsText();
}

}
89 changes: 89 additions & 0 deletions src/main/java/seedu/ggist/model/task/FloatingTask.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package seedu.ggist.model.task;

import java.util.Objects;

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

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

private TaskName taskName;
private Date date;
private Time startTime;
private Time endTime;

private UniqueTagList tags;

/**
* Every field must be present and not null.
*/
public FloatingTask(TaskName taskName, UniqueTagList tags) {
this.taskName = taskName;
this.date = null;
this.startTime = null;
this.endTime = null;
this.tags = new UniqueTagList(tags); // protect internal tags from changes in the arg list
}

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

@Override
public TaskName getTaskName() {
return taskName;
}

@Override
public Date getDate() {
return date;
}

@Override
public Time getStartTime() {
return startTime;
}

@Override
public Time getEndTime() {
return endTime;
}

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

/**
* Replaces this person's tags with the tags in the argument tag list.
*/
public void setTags(UniqueTagList replacement) {
tags.setTags(replacement);
}

@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 int hashCode() {
// use this method for custom fields hashing instead of implementing your own
return Objects.hash(taskName, date, startTime, endTime, tags);
}

@Override
public String toString() {
return getAsText();
}

}
92 changes: 92 additions & 0 deletions src/main/java/seedu/ggist/model/task/GeneralTask.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package seedu.ggist.model.task;

import java.util.Objects;

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

/**
* Represents a Task in the address book.
* Guarantees: details are present and not null, field values are validated.
*/
public abstract class GeneralTask {

private TaskName name;
private UniqueTagList tags;

/**
* Every field must be present and not null.
*/
public GeneralTask(TaskName taskName) {
this.taskName = taskName;
this.tags = new UniqueTagList(tags); // protect internal tags from changes in the arg list
}

/**
* Copy constructor.
*/
public Task(ReadOnlyTask source) {
this(source.getTaskName(), source.getDate(), source.getStartTime(), source.getEndTime(), source.getPriority(), source.getFrequency(), source.getTags());
}

@Override
public TaskName getTaskName() {
return taskName;
}

@Override
public Date getDate() {
return date;
}

@Override
public Time getStartTime() {
return startTime;
}

@Override
public Time getEndTime() {
return endTime;
}

@Override
public Priority getPriority() {
return priority;
}

@Override
public Frequency getFrequency() {
return frequency;
}

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

/**
* Replaces this person's tags with the tags in the argument tag list.
*/
public void setTags(UniqueTagList replacement) {
tags.setTags(replacement);
}

@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 int hashCode() {
// use this method for custom fields hashing instead of implementing your own
return Objects.hash(taksName, date, startTime, endTime, priority, frequency, tags);
}

@Override
public String toString() {
return getAsText();
}

}
Loading