Skip to content

Commit

Permalink
Merge pull request AY2324S1-CS2103T-W15-2#290 from Nid21cs/288-Improv…
Browse files Browse the repository at this point in the history
…e-Code-Quality

288 improve code quality
  • Loading branch information
Nid21cs authored Nov 12, 2023
2 parents b5886c0 + edc453a commit d5bb179
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 21 deletions.
8 changes: 4 additions & 4 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -1075,8 +1075,8 @@ otherwise)

Use case resumes at step 1.

* 1a. The Index provided is invalid.
* 1a1. ProfBook shows an error message.
* 1b. The Index provided is invalid.
* 1b1. ProfBook shows an error message.

Use case resumes at step 1.

Expand All @@ -1096,8 +1096,8 @@ otherwise)

Use case resumes at step 1.

* 1a. The Index provided is invalid.
* 1a1. ProfBook shows an error message.
* 1b. The Index provided is invalid.
* 1b1. ProfBook shows an error message.

Use case resumes at step 1.

Expand Down
7 changes: 6 additions & 1 deletion src/main/java/seedu/address/model/task/Deadline.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
package seedu.address.model.task;


import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.logging.Logger;

import seedu.address.commons.core.LogsCenter;
import seedu.address.ui.DeadlineCard;

/**
* The Deadline class represents a deadline task for the ProfBook.
* It extends the Task class and provides additional methods specific to deadline tasks.
*/
public class Deadline extends Task {
private static final Logger logger = LogsCenter.getLogger(Deadline.class);
private static final DateTimeFormatter OUTPUT_DATETIME_FORMATTER =
DateTimeFormatter.ofPattern("EEEE, MMMM d, yyyy hh:mm a");

private final LocalDateTime dueBy;


/**
* Constructs a new Deadline object with the given description and deadline.
* @param description the description of the Deadline task
Expand All @@ -23,6 +27,7 @@ public class Deadline extends Task {
public Deadline(String description, LocalDateTime deadline) {
super(description);
this.dueBy = deadline;
logger.info("Created Deadline: " + description + " (by: " + formatDueBy() + ")");
}

/**
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/seedu/address/model/task/ToDo.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
package seedu.address.model.task;

import java.util.logging.Logger;

import seedu.address.commons.core.LogsCenter;
import seedu.address.ui.TodoCard;

/**
* The ToDo class represents a deadline task for the ProfBook.
* The ToDo class represents a ToDo task for the ProfBook.
* It extends the Task class and provides additional methods specific to ToDo tasks.
*/
public class ToDo extends Task {
private static final Logger logger = LogsCenter.getLogger(ToDo.class);

/**
* Constructs a {@code ToDo} with given {@code description}.
*/
public ToDo(String description) {
super(description);
logger.info("Created ToDo: " + description);
}

/**
Expand Down
20 changes: 10 additions & 10 deletions src/test/java/seedu/address/storage/JsonAdaptedGroupTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,30 @@
import seedu.address.model.id.GroupId;
import seedu.address.model.profbook.Group;
import seedu.address.model.profbook.Name;
import seedu.address.testutil.GroupBuilder;
import seedu.address.testutil.TypicalGroups;


public class JsonAdaptedGroupTest {

private static final Group GROUP_ONE = TypicalGroups.GROUP_ONE;
private static final Group GROUP_TWO = TypicalGroups.GROUP_TWO;

@Test
public void toModelType_validGroupDetails_returnsGroup() throws Exception {
Group grp = new GroupBuilder().build();
JsonAdaptedGroup group = new JsonAdaptedGroup(grp);
assertEquals(grp, group.toModelType());
JsonAdaptedGroup group = new JsonAdaptedGroup(GROUP_ONE);
assertEquals(GROUP_ONE, group.toModelType());
}

@Test
public void toModelType_emptyTask_returnsGroup() throws Exception {
Group grp = new GroupBuilder().build();
JsonAdaptedGroup group = new JsonAdaptedGroup(grp);
assertEquals(grp, group.toModelType());
JsonAdaptedGroup group = new JsonAdaptedGroup(GROUP_TWO);
assertEquals(GROUP_TWO, group.toModelType());

}
@Test
public void toModelType_emptyStudent_returnsGroup() throws Exception {
Group grp = new GroupBuilder().build();
JsonAdaptedGroup group = new JsonAdaptedGroup(grp);
assertEquals(grp, group.toModelType());
JsonAdaptedGroup group = new JsonAdaptedGroup(GROUP_ONE);
assertEquals(GROUP_ONE, group.toModelType());

}

Expand Down
14 changes: 9 additions & 5 deletions src/test/java/seedu/address/storage/JsonAdaptedStudentTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,30 @@
import static seedu.address.testutil.StudentBuilder.DEFAULT_PHONE;

import java.util.ArrayList;
import java.util.logging.Logger;

import org.junit.jupiter.api.Test;

import seedu.address.commons.core.LogsCenter;
import seedu.address.commons.exceptions.IllegalValueException;
import seedu.address.model.profbook.Student;
import seedu.address.testutil.StudentBuilder;
import seedu.address.testutil.TypicalStudents;

public class JsonAdaptedStudentTest {

private static final Logger logger = LogsCenter.getLogger(JsonAdaptedStudentTest.class);
private static final Student student = TypicalStudents.ALICE;
@Test
public void toModelType_validStudentDetails_returnsStudent() throws Exception {
Student student = new StudentBuilder().build();
logger.info("Testing toModelType for valid student");
JsonAdaptedStudent jsonAdaptedStudent = new JsonAdaptedStudent(student);
assertEquals(student, jsonAdaptedStudent.toModelType());
}

@Test
public void toModelType_emptyTask_returnsStudent() throws Exception {
Student grp = new StudentBuilder().build();
JsonAdaptedStudent student = new JsonAdaptedStudent(grp);
assertEquals(grp, student.toModelType());
JsonAdaptedStudent jsonAdaptedStudent = new JsonAdaptedStudent(student);
assertEquals(student, jsonAdaptedStudent.toModelType());
}

@Test
Expand Down Expand Up @@ -133,6 +136,7 @@ public void toModelType_invalidId_throwsIllegalValueException() throws Exception

@Test
public void toModelType_nullId_throwsIllegalValueException() throws Exception {
logger.info("Testing toModelType with null ID should throw excepetion");
JsonAdaptedStudent student = new JsonAdaptedStudent(DEFAULT_NAME,
DEFAULT_PHONE,
DEFAULT_EMAIL,
Expand Down

0 comments on commit d5bb179

Please sign in to comment.