Skip to content

Commit

Permalink
Merge branch 'master' into update-ugdg
Browse files Browse the repository at this point in the history
  • Loading branch information
Wxy2003-xy authored Nov 11, 2024
2 parents d420470 + f309143 commit 6d1d35b
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 16 deletions.
6 changes: 3 additions & 3 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -432,12 +432,12 @@ otherwise)

- **3a.** The command format is incorrect (e.g., index not provided).
- **3a1.** AddressBook displays an error message:
```
`
Invalid command format!
delete: Deletes the person identified by the index number used in the displayed person list.
Parameters: INDEX (must be a positive integer)
Example: delete 1
```
`
- **Use case resumes at Step 2.**

- **4a.** The contact index is invalid or out of bounds.
Expand Down Expand Up @@ -553,7 +553,7 @@ otherwise)
`Example: log 1 l/Met for price negotiation.`

`Example: log 2 d/2024-11-11 l/ Offered discount`

- **2a2.** The Salesperson corrects the `index` and reissues the command.
- **Use case resumes from Step 2.**

Expand Down
2 changes: 1 addition & 1 deletion docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ RealConnect is a **desktop app for managing contacts, optimized for use via a Co

1. Ensure you have Java `17` or above installed in your Computer.

2. Download the latest `.jar` file from [here](https://github.com/se-edu/addressbook-level3/releases).
2. Download the latest `.jar` file from [here](https://github.com/AY2425S1-CS2103-F09-2/tp/releases).

3. Copy the file to the folder you want to use as the _home folder_ for your AddressBook.

Expand Down
Binary file modified docs/images/Ui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class AddPropertyCommand extends Command {
+ PREFIX_PRICE + "PRICE\n"
+ "Example: " + COMMAND_WORD + " 1 "
+ PREFIX_PROPERTY_ADDRESS + "123 Main St "
+ PREFIX_TOWN + "New York "
+ PREFIX_TYPE + "Condo "
+ PREFIX_SIZE + "85 "
+ PREFIX_BEDROOMS + "2 "
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/seedu/address/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import java.time.DateTimeException;
import java.time.LocalDate;
import java.time.format.DateTimeParseException;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
Expand Down Expand Up @@ -103,10 +104,14 @@ public static Remark parseRemark(String remark) {
public static Birthday parseBirthday(String birthday) throws ParseException {
requireNonNull(birthday);
String trimmedBirthday = birthday.trim();
if (!Birthday.isValidBirthday(trimmedBirthday)) {
throw new ParseException(Birthday.MESSAGE_INVALID_BIRTHDAY_AFTER_PRESENT);
try {
if (!Birthday.isValidBirthday(trimmedBirthday)) {
throw new ParseException(Birthday.MESSAGE_INVALID_BIRTHDAY_AFTER_PRESENT);
}
return new Birthday(trimmedBirthday);
} catch (DateTimeParseException dtpe) {
throw new ParseException(MESSAGE_INVALID_DATE_FORMAT);
}
return new Birthday(trimmedBirthday);
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/main/java/seedu/address/model/person/Flags.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* Represent a set of preset labels to each person. Flags enables grouping of persons by multiple criteria in descending
* significance.
* Guarantee: Immutable.
* Note: this is a utility class for future feature: group by tags. Not used in app version v1.6.
* */
public class Flags {
private Set<PresetFlags> flagSet = new HashSet<>();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/ui/HelpWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
public class HelpWindow extends UiPart<Stage> {

public static final String USERGUIDE_URL = "https://se-education.org/addressbook-level3/UserGuide.html";
public static final String USERGUIDE_URL = "https://ay2425s1-cs2103-f09-2.github.io/tp/UserGuide.html";
public static final String HELP_MESSAGE = "Refer to the user guide: " + USERGUIDE_URL;

private static final Logger logger = LogsCenter.getLogger(HelpWindow.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ public class CommandTestUtil {
public static final String INVALID_ADDRESS_DESC = " " + PREFIX_ADDRESS; // empty string not allowed for addresses
public static final String INVALID_DATE_DESC = " " + PREFIX_BIRTHDAY + "2002-02-30"; // empty string not allowed
// for birthdays
public static final String INVALID_DATE_AGAIN_DESC = " " + PREFIX_BIRTHDAY + "2024-13-01";
public static final String INVALID_BIRTHDAY_EARLY_DESC = " " + PREFIX_BIRTHDAY + "1908-04-22";
public static final String INVALID_DATE_AGAIN_DESC = " " + PREFIX_BIRTHDAY + "3rd March 1970";
public static final String INVALID_BIRTHDAY_LATE_DESC = " " + PREFIX_BIRTHDAY + LocalDate.now()
.plusDays(10).toString();
public static final String INVALID_TAG_DESC = " " + PREFIX_TAG + "hubby*"; // '*' not allowed in tags
Expand Down
12 changes: 12 additions & 0 deletions src/test/java/seedu/address/logic/parser/AddCommandParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import static seedu.address.logic.commands.CommandTestUtil.EMAIL_DESC_AMY;
import static seedu.address.logic.commands.CommandTestUtil.EMAIL_DESC_BOB;
import static seedu.address.logic.commands.CommandTestUtil.INVALID_ADDRESS_DESC;
import static seedu.address.logic.commands.CommandTestUtil.INVALID_DATE_AGAIN_DESC;
import static seedu.address.logic.commands.CommandTestUtil.INVALID_DATE_DESC;
import static seedu.address.logic.commands.CommandTestUtil.INVALID_EMAIL_DESC;
import static seedu.address.logic.commands.CommandTestUtil.INVALID_NAME_DESC;
import static seedu.address.logic.commands.CommandTestUtil.INVALID_PHONE_DESC;
Expand Down Expand Up @@ -198,6 +200,16 @@ public void parse_invalidValue_failure() {
assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + INVALID_ADDRESS_DESC
+ REMARK_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Address.MESSAGE_CONSTRAINTS);

// invalid birthday
assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB
+ REMARK_DESC_BOB + INVALID_DATE_DESC + TAG_DESC_HUSBAND + TAG_DESC_FRIEND,
Messages.MESSAGE_INVALID_DATE_FORMAT);

// another invalid birthday
assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB
+ REMARK_DESC_BOB + INVALID_DATE_AGAIN_DESC + TAG_DESC_HUSBAND + TAG_DESC_FRIEND,
Messages.MESSAGE_INVALID_DATE_FORMAT);

// invalid tag
assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB
+ REMARK_DESC_BOB + INVALID_TAG_DESC + VALID_TAG_FRIEND, Tag.MESSAGE_CONSTRAINTS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.logic.Messages.MESSAGE_INVALID_DATE_FORMAT;
import static seedu.address.logic.commands.CommandTestUtil.INVALID_BIRTHDAY_EARLY_DESC;
import static seedu.address.logic.commands.CommandTestUtil.INVALID_BIRTHDAY_LATE_DESC;
import static seedu.address.logic.commands.CommandTestUtil.INVALID_DATE_DESC;
import static seedu.address.logic.commands.CommandTestUtil.VALID_BIRTHDAY_AMY;
Expand Down Expand Up @@ -51,10 +50,8 @@ public void parse_missingCompulsoryField_failure() {
public void parse_invalidValue_failure() {
Index targetIndex = INDEX_FIRST_PERSON;
String userInput1 = targetIndex.getOneBased() + INVALID_DATE_DESC;
String userInput2 = targetIndex.getOneBased() + INVALID_BIRTHDAY_EARLY_DESC;
String userInput3 = targetIndex.getOneBased() + INVALID_BIRTHDAY_LATE_DESC;

String expectedMessage = MESSAGE_INVALID_BIRTHDAY_AFTER_PRESENT;

// Invalid date
assertParseFailure(parser, userInput1, MESSAGE_INVALID_DATE_FORMAT);
Expand Down
27 changes: 27 additions & 0 deletions src/test/java/seedu/address/logic/parser/ParserUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class ParserUtilTest {
private static final String WHITESPACE = " \t\r\n";
private static final String VALID_DATE_STRING = "1970-01-01";
private static final String INVALID_DATE_STRING = "01-01-1970";
private static final String ANOTHER_INVALID_DATE_STRING = "1st January 1970";

@Test
public void parseIndex_invalidInput_throwsParseException() {
Expand Down Expand Up @@ -206,4 +207,30 @@ public void parseDate_validDateFormat_returnLocalDate() throws Exception {
public void parseDate_invalidDateFormat_throwsDateTimeException() throws ParseException {
assertThrows(ParseException.class, () -> ParserUtil.parseDate(INVALID_DATE_STRING));
}

@Test
public void parseInteger_validIntegerWithoutWhitespace_returnsInteger() throws Exception {
assertEquals(123, ParserUtil.parseInteger("123"));
}

@Test
public void parseInteger_validIntegerWithWhitespace_returnsTrimmedInteger() throws Exception {
assertEquals(123, ParserUtil.parseInteger(" 123 "));
}

@Test
public void parseInteger_invalidInteger_throwsParseException() {
assertThrows(ParseException.class, () -> ParserUtil.parseInteger("123abc"));
}

@Test
public void parseInteger_nullInput_throwsNullPointerException() {
assertThrows(NullPointerException.class, () -> ParserUtil.parseInteger(null));
}

@Test
public void parseBirthday_invalidDateFormat_throwsDateTimeException() throws ParseException {
assertThrows(ParseException.class, () -> ParserUtil.parseBirthday(INVALID_DATE_STRING));
assertThrows(ParseException.class, () -> ParserUtil.parseBirthday(ANOTHER_INVALID_DATE_STRING));
}
}
4 changes: 1 addition & 3 deletions src/test/java/seedu/address/model/person/FlagsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public void testGetNumberOfMatchingFlags() {
testFlags.add(PresetFlags.ARCHIVED);

assertEquals(2, flags.getNumberOfMatchingFlags(testFlags));

// Test with a set containing no matching flags.
testFlags.clear();
testFlags.add(PresetFlags.BUYER);
Expand All @@ -59,7 +58,7 @@ public void testGetWeightedFlags() {
Flags flags = new Flags(PresetFlags.FAVOURITE, PresetFlags.BUYER, PresetFlags.SELLER);

// Test weight calculation for matching flags.
// Assuming the weight is calculated as 2^index in reverse order:
// The weight is calculated as 2^index in reverse order:
// FAVOURITE: index 0 -> 2^0 = 1
// ARCHIVED: index 1 -> 2^1 = 2
// BUYER: index 2 -> 2^2 = 4
Expand All @@ -85,7 +84,6 @@ public void testEmptyFlags() {
PresetFlags.ARCHIVED, PresetFlags.BUYER, PresetFlags.SELLER));
assertEquals(0, emptyFlags.getNumberOfMatchingFlags(new HashSet<>()));

// Ensure that no flags are present.
assertEquals(0, emptyFlags.flagIsPresent(PresetFlags.FAVOURITE));
assertEquals(0, emptyFlags.flagIsPresent(PresetFlags.ARCHIVED));
}
Expand Down

0 comments on commit 6d1d35b

Please sign in to comment.