Skip to content

Commit 786908a

Browse files
Merge pull request #8 from proto-aiken-13/branch-A-Miscallaneous
branch miscallaneous
2 parents 22217cd + 199d1c3 commit 786908a

File tree

6 files changed

+47
-7
lines changed

6 files changed

+47
-7
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/**
99
* Manages the date and time based on a user input.
1010
*/
11-
public class DateAndTime {
11+
public class DateFormatter {
1212

1313
/**
1414
* Parses a given string date. For dates only.

src/main/java/duke/Deadline.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class Deadline extends Task {
1717
*/
1818
public Deadline(String taskname, String byDate) {
1919
super(taskname);
20-
this.byDate = DateAndTime.parseDay(byDate, "MMM d yyyy");
20+
this.byDate = DateFormatter.parseDay(byDate, "MMM d yyyy");
2121
}
2222

2323
/**

src/main/java/duke/Event.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ public class Event extends Task {
1919
*/
2020
public Event(String classname, String startTime, String endTime) {
2121
super(classname);
22-
this.startTime = DateAndTime.parseDay(startTime, "MMM d yyyy");
23-
this.endTime = DateAndTime.parseDay(endTime, "MMM d yyyy");
22+
this.startTime = DateFormatter.parseDay(startTime, "MMM d yyyy");
23+
this.endTime = DateFormatter.parseDay(endTime, "MMM d yyyy");
2424
}
2525

2626
/**

src/main/java/duke/Parser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ private Command editTask(String editType, String index) {
123123
if (index.isEmpty()) {
124124
return new TaskError("delete");
125125
}
126-
return new TaskMarker(Integer.parseInt(index), tasks);
126+
return new TaskDeleter(Integer.parseInt(index), tasks);
127127

128128
default:
129129
return new TaskError("other");

src/test/java/duke/DateAndTimeTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class DateAndTimeTest {
1616
*/
1717
@Test
1818
public void validTest() {
19-
DateAndTime test1 = new DateAndTime();
19+
DateFormatter test1 = new DateFormatter();
2020
assertTrue(test1.isValidDate("2023-04-01", "2023-04-02"));
2121
}
2222

@@ -25,6 +25,6 @@ public void validTest() {
2525
*/
2626
@Test
2727
public void dateStringTest() {
28-
assertEquals("Apr 01 2023", DateAndTime.parseDay("2023-04-01", "MMM dd YYYY"));
28+
assertEquals("Apr 01 2023", DateFormatter.parseDay("2023-04-01", "MMM dd YYYY"));
2929
}
3030
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package duke;
2+
3+
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
import static org.junit.jupiter.api.Assertions.assertFalse;
5+
import static org.junit.jupiter.api.Assertions.assertTrue;
6+
7+
import org.junit.jupiter.api.Test;
8+
9+
/**
10+
* Test cases for the {@link Deadline} class.
11+
*/
12+
public class DeadlineTest {
13+
/**
14+
* Test the {@link Deadline#toString()} method.
15+
*/
16+
@Test
17+
public void toStringTest() {
18+
Deadline test1 = new Deadline("HAMBURGER", "2023-09-24" );
19+
assertEquals(test1.toString(), "[D][ ] HAMBURGER (by: Sep 24 2023)");
20+
}
21+
22+
/**
23+
* Test the {@link Deadline#isDone()} method.
24+
*/
25+
@Test
26+
public void doneTest() {
27+
Deadline test2 = new Deadline("HAMBURGER", "2023-09-25");
28+
test2.done();
29+
assertTrue(test2.isDone());
30+
}
31+
32+
/**
33+
* Test the {@link Deadline#isDone()} method.
34+
*/
35+
@Test
36+
public void unDoneTest() {
37+
Deadline test3 = new Deadline("FRIES", "2023-09-06");
38+
assertFalse(test3.isDone());
39+
}
40+
}

0 commit comments

Comments
 (0)