11package duke .commands ;
22
3- import java .time .LocalDateTime ;
4-
5- import duke .tasks .Deadline ;
3+ import duke .tasks .Task ;
64import duke .tasks .TaskList ;
7- import duke .ui .Ui ;
85
96/**
10- * Handles the logic of adding a <code>Deadline </code> to the to-do list.
7+ * Handles the logic of adding a <code>Task </code> to the to-do list.
118 */
12- public class AddDeadlineCommand extends Command {
13- private final Deadline deadline ;
9+ public class AddTaskCommand extends Command {
10+ private final Task task ;
1411
1512 /**
16- * Initializes a command to add a <code>Deadline </code> with a description and a datetime .
13+ * Initializes a command to add a <code>Task </code> to the to-do list .
1714 *
18- * @param description Description of the deadline task.
19- * @param byDateTime The task's deadline.
15+ * @param task The <code>Task</code> to be added to the to-do list.
2016 */
21- public AddDeadlineCommand ( String description , LocalDateTime byDateTime ) {
22- this .deadline = new Deadline ( description , byDateTime ) ;
17+ public AddTaskCommand ( Task task ) {
18+ this .task = task ;
2319 }
2420
2521 /**
@@ -32,21 +28,23 @@ public boolean isExit() {
3228 }
3329
3430 /**
35- * Adds the created <code>Deadline </code> to the input <code>TaskList</code>.
31+ * Adds the created <code>Task </code> to the input <code>TaskList</code>.
3632 *
3733 * @param tasks A collection of <code>Task</code> objects representing the application's state.
3834 */
3935 public void execute (TaskList tasks ) {
40- tasks .addTask (this .deadline );
36+ tasks .addTask (this .task );
4137 }
4238
4339 /**
44- * Computes a response to notify the users the adding of the <code>Deadline </code>.
40+ * Computes a response to notify the users the adding of the <code>Task </code>.
4541 *
4642 * @param tasks A collection of <code>Task</code> objects representing the application's state.
4743 * @return A <code>String</code> to respond to the adding of the <code>Deadline</code>.
4844 */
4945 public String getResponse (TaskList tasks ) {
50- return Ui .getAddTaskResponse (tasks , this .deadline );
46+ return "Got it. I've added this task:\n "
47+ + this .task .getStatusString () + "\n "
48+ + "Now you have " + tasks .getSize () + " task(s) in the list." ;
5149 }
5250}
0 commit comments