Skip to content

Commit

Permalink
Edit Code reuse declaration (#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
LiuMC-SG authored Apr 27, 2023
2 parents 1acc801 + 24782bf commit 216b578
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public class AddTaskCommand extends AddItemCommand<Task> {
+ PREFIX_NAME + "Sort Inventory "
+ PREFIX_DEADLINE + "01/01/2024 "
+ PREFIX_STATUS + "N ";
//@@author

/**
* Creates an AddTaskCommand to add the specified {@code Task}.
Expand All @@ -35,4 +34,5 @@ public class AddTaskCommand extends AddItemCommand<Task> {
public AddTaskCommand(Task task) {
super(task, ModelEnum.TASK);
}
//@@author
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ public class ListTaskCommand extends ListItemCommand<Task> {
//Reused from AB3 with minor modifications
public static final String COMMAND_WORD = "list_task";
public static final String COMMAND_WORD_SHORTCUT = "list_t";
//@@author

/**
* Creates a ListTaskCommand to list all the tasks.
*/
public ListTaskCommand() {
super(ModelEnum.TASK);
}
//@@author
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import trackr.logic.parser.exceptions.ParseException;
import trackr.model.order.SortOrdersComparator;

//@@author HmuuMyatMoe-reused
//Reused from AB3 with minor modifications
/**
* Parses input arguments and creates a new SortOrdersCommand object.
*/
Expand Down Expand Up @@ -40,3 +42,4 @@ public SortOrdersCommand parse(String args) throws ParseException {
return new SortOrdersCommand(comparator);
}
}
//@@author
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
import trackr.logic.parser.exceptions.ParseException;
import trackr.model.task.SortTasksComparator;

//Solution below is adapted from AB3
//@@author HmuuMyatMoe-reused
//Reused from AB3 with minor modifications
/**
* Parses input arguments and creates a new SortTasksCommand object.
*/
Expand Down Expand Up @@ -41,3 +42,4 @@ public SortTasksCommand parse(String args) throws ParseException {
return new SortTasksCommand(comparator);
}
}
//@@author
4 changes: 3 additions & 1 deletion src/main/java/trackr/model/order/OrderDeadline.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
* Guarantees: immutable; is valid as declared in {@link #isValidDeadline(String)}
*/
public class OrderDeadline extends Deadline {

//@@author HmuuMyatMoe-reused
//Reused from AB3 with minor modifications
public static final String MESSAGE_CONSTRAINTS =
"Order deadline should only contain numeric values "
+ "in the format \"DD/MM/YYYY\" and it should not be blank.";
//@@author


/**
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/trackr/model/task/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* Guarantees: details are present and not null, field values are validated, immutable.
*/
public class Task extends Item {
//@@author HmuuMyatMoe-reused
//Reused from AB3 with minor modifications

// Data fields
private final TaskName taskName;
Expand Down Expand Up @@ -59,6 +61,7 @@ public TaskStatus getTaskStatus() {
public LocalDateTime getTimeAdded() {
return timeAdded;
}
//@@author

/**
* Compares 2 tasks using their time added.
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/trackr/model/task/TaskDeadline.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* Represents a Task's deadline in the task list.
* Guarantees: immutable; is valid as declared in {@link #isValidDeadline(String)}
*/
//Solution below adapted from AB3
public class TaskDeadline extends Deadline {

//@@author HmuuMyatMoe-reused
//Reused from AB3 with minor modifications
public static final String MESSAGE_CONSTRAINTS =
"Task deadline should only contain numeric values in the format \"DD/MM/YYYY\" and it should not be blank.";

Expand All @@ -21,5 +21,6 @@ public class TaskDeadline extends Deadline {
public TaskDeadline(String deadline) {
super(deadline, "Task");
}
//@@author
}

3 changes: 1 addition & 2 deletions src/main/java/trackr/model/task/TaskName.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ public class TaskName extends Name {
*
* @param taskName A valid task name.
*/
//@@author
public TaskName(String taskName) {
super(taskName, "Task");
}

//@@author
}

3 changes: 3 additions & 0 deletions src/main/java/trackr/model/util/SampleDataUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ public static Set<Tag> getTagSet(String... strings) {
.collect(Collectors.toSet());
}

//@@author HmuuMyatMoe-reused
//Reused from AB3 with minor modifications
public static Task[] getSampleTasks() {
return new Task[] {
new Task(new TaskName("Buy flour"), new TaskDeadline("01/01/2024"),
Expand All @@ -86,6 +88,7 @@ public static Task[] getSampleTasks() {
new TaskStatus("N"))
};
}
//@@author

//@@author liumc-sg-reused
public static ReadOnlyTaskList getSampleTaskList() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
/**
* Contains integration tests (interaction with the Model) for {@code AddTaskCommand}.
*/
//@@author hmuumyatmoe-reused
public class AddTaskCommandIntegrationTest {

private Model model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import trackr.testutil.TaskBuilder;
import trackr.testutil.TestUtil.ModelStub;

//@@author hmuumyatmoe-reused
public class AddTaskCommandTest {

//@@author HmuuMyatMoe-reused
Expand Down Expand Up @@ -77,9 +76,7 @@ public void equals() {
// different task -> returns false
assertFalse(addSortInventoryCommand.equals(addBuyEggsCommand));
}
//@@author

//Solution below adapted from AB3.
/**
* A Model stub that contains a single task.
*/
Expand All @@ -97,7 +94,9 @@ public <T extends Item> boolean hasItem(T item, ModelEnum modelEnum) {
return this.task.isSameItem((Task) item);
}
}
//@@author

//@@author liumc-sg-reused
/**
* A Model stub that always accept the task being added.
*/
Expand All @@ -121,5 +120,5 @@ public ReadOnlyTaskList getTaskList() {
return new TaskList();
}
}

//@@author
}
7 changes: 5 additions & 2 deletions src/test/java/trackr/model/TaskListTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public void resetData_withDuplicateTasks_throwsDuplicateTaskException() {
public void hasTask_nullTask_throwsNullPointerException() {
assertThrows(NullPointerException.class, () -> taskList.hasItem(null));
}
//@@author

@Test
public void hasTask_taskNotInTaskList_returnsFalse() {
Expand All @@ -74,6 +75,8 @@ public void hasTask_taskInTaskList_returnsTrue() {
}
//@@author

//@@author HmuuMyatMoe-reused
//Reused from AB3 with minor modifications
@Test
public void hasTask_taskWithSameIdentityFieldsInTaskList_returnsTrue() {
taskList.addItem(SORT_INVENTORY_N);
Expand Down Expand Up @@ -103,6 +106,8 @@ public void setTaskList_withDuplicateTasks_throwsDuplicateTaskException() {
}
//@@author

//@@author HmuuMyatMoe-reused
//Reused from AB3 with minor modifications
@Test
public void setTaskList_withDifferentTask_success() {
TaskList expectedTaskList = new TaskList();
Expand All @@ -114,8 +119,6 @@ public void setTaskList_withDifferentTask_success() {
assertEquals(expectedTaskList, taskList);
}

//@@author HmuuMyatMoe-reused
//Reused from AB3 with minor modifications
@Test
public void getTaskList_modifyList_throwsUnsupportedOperationException() {
assertThrows(UnsupportedOperationException.class, () -> taskList.getItemList().remove(0));
Expand Down
4 changes: 3 additions & 1 deletion src/test/java/trackr/model/order/OrderStatusTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public void constructor_noArguments_success() {
}
//@@author

//Solution for isValidOrderStatus test below is adapted from AB3
//@@author HmuuMyatMoe-reused
//Reused from AB3 with minor modifications
@Test
public void isValidOrderStatus() {
// null order status
Expand All @@ -59,6 +60,7 @@ public void isValidOrderStatus() {
assertTrue(OrderStatus.isValidStatus("i", OrderStatus.STATUSES)); // small letter
assertTrue(OrderStatus.isValidStatus("d", OrderStatus.STATUSES)); // small letter
}
//@@author

//@@author chongweiguan-reused
@Test
Expand Down

0 comments on commit 216b578

Please sign in to comment.