Skip to content

Commit

Permalink
Resolve Fallman2 review comments
Browse files Browse the repository at this point in the history
Resolved all comments except for:
-ParserUtil lines 136-139
-ParserUtil lines 154-157
  • Loading branch information
lihongguang00 committed Oct 14, 2023
1 parent 3378103 commit 5be4fba
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/logic/LogicManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class LogicManager implements Logic {
public LogicManager(Model model, Storage storage) {
this.model = model;
this.storage = storage;
this.uniMateParser = new UniMateParser();
uniMateParser = new UniMateParser();
}

@Override
Expand Down
22 changes: 0 additions & 22 deletions src/main/java/seedu/address/logic/parser/ComponentParser.java

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/java/seedu/address/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public static Set<Tag> parseTags(Collection<String> tags) throws ParseException
public static EventDescription parseEventDescription(String description) throws ParseException {
requireNonNull(description);
String trimmedDescription = description.trim();
if (trimmedDescription.isEmpty()) {
if (!EventDescription.isValid(description)) {
throw new ParseException(EventDescription.MESSAGE_CONSTRAINTS);
}
return new EventDescription(trimmedDescription);
Expand Down
13 changes: 9 additions & 4 deletions src/main/java/seedu/address/logic/parser/UniMateParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,23 @@
import seedu.address.logic.parser.exceptions.ParseException;

/**
* Parses user input for address book component of application.
* Parses user input for UniMate.
*/
public class UniMateParser extends ComponentParser {
public class UniMateParser {

/**
* Used for initial separation of command word and args.
*/
private static final Pattern BASIC_COMMAND_FORMAT = Pattern.compile("(?<commandWord>\\S+)(?<arguments>.*)");
private static final Logger logger = LogsCenter.getLogger(UniMateParser.class);

@Override
/**
* Parses a user input string into the appropriate command object.
*
* @param userInput The user input string to be parsed.
* @return A command object corresponding to the user's command.
* @throws ParseException If the user input cannot be parsed successfully.
*/
public Command parseCommand(String userInput) throws ParseException {
final Matcher matcher = BASIC_COMMAND_FORMAT.matcher(userInput.trim());
if (!matcher.matches()) {
Expand Down Expand Up @@ -80,5 +86,4 @@ public Command parseCommand(String userInput) throws ParseException {
throw new ParseException(MESSAGE_UNKNOWN_COMMAND);
}
}

}
6 changes: 3 additions & 3 deletions src/main/java/seedu/address/model/ModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public ModelManager(ReadOnlyAddressBook addressBook, ReadOnlyUserPrefs userPrefs
this.addressBook = new AddressBook(addressBook);
this.userPrefs = new UserPrefs(userPrefs);
filteredPersons = new FilteredList<>(this.addressBook.getPersonList());
this.calendar = new Calendar();
calendar = new Calendar();
}

public ModelManager() {
Expand Down Expand Up @@ -121,14 +121,14 @@ public void setPerson(Person target, Person editedPerson) {
//=========== Calendar ===================================================================================
@Override
public boolean canAddEvent(Event event) {
return this.calendar.canAddEvent(event);
return calendar.canAddEvent(event);
}

@Override
public void addEvent(Event event) {
requireAllNonNull(event);

this.calendar.addEvent(event);
calendar.addEvent(event);
}

//=========== Filtered Person List Accessors =============================================================
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/seedu/address/model/event/EventDescription.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ public static EventDescription createUnusedDescription() {
return new EventDescription("THIS IS A PLACEHOLDER");
}

/**
* Checks if the given string is a valid description for creating a EventDescription object.
*
* @param description description String to be checked.
* @return true if description is non-empty, false if it is empty.
*/
public static boolean isValid(String description) {
requireNonNull(description);
return !description.isEmpty();
}

/**
* Retrieve the underlying String of the description.
*
Expand All @@ -41,6 +52,7 @@ public static EventDescription createUnusedDescription() {
public String getDescription() {
return this.description;
}

@Override
public boolean equals(Object other) {
if (other == this) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/seedu/address/model/event/EventPeriod.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/**
* Represents a period in time when an event will occur.
*/
public class EventPeriod {
public class EventPeriod implements Comparable<EventPeriod> {
public static final String MESSAGE_CONSTRAINTS = "The start date and time and end date and time should "
+ "be in the format 'yyyy-MM-dd HH:mm' where:\n"
+ " -'yyyy' is the year.\n"
Expand Down Expand Up @@ -91,6 +91,7 @@ public boolean isOverlapping(EventPeriod other) {
* @param other The EventPeriod to compare with.
* @return 1 if this EventPeriod is after the other, -1 if it's before, 0 if they are the same.
*/
@Override
public int compareTo(EventPeriod other) {
requireNonNull(other);
if (this.start.isBefore(other.start)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package seedu.address.model.event;

import org.junit.jupiter.api.Test;

public class AllDaysEventListManagerTest {
@Test
public void constructorTest() {

}
}
11 changes: 11 additions & 0 deletions src/test/java/seedu/address/model/event/EventDescriptionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ public void constructorTest() {
assertThrows(InvalidDescriptionException.class, () -> new EventDescription(INVALID_DESCRIPTION));
}

@Test
public void isValidTest() {
assertThrows(NullPointerException.class, () -> EventDescription.isValid(null));

assertFalse(EventDescription.isValid(INVALID_DESCRIPTION));

assertTrue(EventDescription.isValid(VALID_DESCRIPTION));

assertTrue(EventDescription.isValid(VALID_UNUSED_DESCRIPTION));
}

@Test
public void createUnusedDescriptionTest() {
assertEquals(EventDescription.createUnusedDescription().getDescription(), VALID_UNUSED_DESCRIPTION);
Expand Down

0 comments on commit 5be4fba

Please sign in to comment.