Skip to content

Commit

Permalink
Update naming convention and minor UI fixes (#104)
Browse files Browse the repository at this point in the history
* Update naming for add student and minor command messages fixes

* Fix styling errors
  • Loading branch information
Jajared authored Mar 20, 2024
1 parent 6f3de9f commit 28ddf76
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ public class AddClassCommand extends Command {
public static final String MESSAGE_DUPLICATE_CLASS = "%1$s %2$s already added!";
public static final String COMMAND_WORD = "/add_class";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a class with the module code specified\n"
+ "Parameters:" + PREFIX_MODULECODE + "MODULE_CODE (must be a String) "
+ PREFIX_TUTORIALCLASS + "TUTORIAL_CLASS (must be a String)"
+ "Example: " + COMMAND_WORD + PREFIX_MODULECODE + " CS2103T "
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a class with the module code and"
+ " tutorial class specified\n"
+ "Parameters: " + PREFIX_MODULECODE + "MODULE_CODE "
+ PREFIX_TUTORIALCLASS + "TUTORIAL_CLASS \n"
+ "Example: " + COMMAND_WORD + " " + PREFIX_MODULECODE + "CS2103T "
+ PREFIX_TUTORIALCLASS + "T09";

private final ModuleCode module;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@
/**
* Adds a person to TAHelper.
*/
public class AddCommand extends Command {
public class AddStudentCommand extends Command {

public static final String COMMAND_WORD = "/add_student";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a person to TAHelper. "
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a person to TAHelper.\n"
+ "Parameters: "
+ PREFIX_NAME + "NAME "
+ PREFIX_EMAIL + "EMAIL "
+ PREFIX_STUDENTID + "STUDENT ID "
+ "[" + PREFIX_TAG + "TAG]...\n"
+ "Example: " + COMMAND_WORD + " "
+ PREFIX_NAME + "Zack "
+ PREFIX_STUDENTID + "A12345678Z "
+ PREFIX_STUDENTID + "A1234567Z "
+ PREFIX_EMAIL + "Zack@example.com "
+ PREFIX_TAG + "Student ";

Expand All @@ -39,7 +39,7 @@ public class AddCommand extends Command {
/**
* Creates an AddCommand to add the specified {@code Person}
*/
public AddCommand(Person person) {
public AddStudentCommand(Person person) {
requireNonNull(person);
toAdd = person;
}
Expand All @@ -63,11 +63,11 @@ public boolean equals(Object other) {
}

// instanceof handles nulls
if (!(other instanceof AddCommand)) {
if (!(other instanceof AddStudentCommand)) {
return false;
}

AddCommand otherAddCommand = (AddCommand) other;
AddStudentCommand otherAddCommand = (AddStudentCommand) other;
return toAdd.equals(otherAddCommand.toAdd);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public class DeleteClassCommand extends Command {

public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Deletes a class with the module code and tutorial class specified\n"
+ "Parameters:" + PREFIX_MODULECODE + "MODULE_CODE (must be a String) "
+ PREFIX_TUTORIALCLASS + "TUTORIAL_CLASS (must be a String)"
+ "Example: " + COMMAND_WORD + PREFIX_MODULECODE + " CS2103T "
+ "Parameters:" + PREFIX_MODULECODE + "MODULE_CODE "
+ PREFIX_TUTORIALCLASS + "TUTORIAL_CLASS\n"
+ "Example: " + COMMAND_WORD + " " + PREFIX_MODULECODE + " CS2103T "
+ PREFIX_TUTORIALCLASS + "T09";

private final ModuleCode module;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public abstract class DeleteStudentCommand extends Command {
public static final String COMMAND_WORD = "/delete_student";

public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Deletes the student identified by the student ID or email used in the displayed students list.\n"
+ "Parameters: IDENTIFIER (must be a index, valid student ID or a valid email address)\n"
+ ": Deletes the student identified by parameter in the displayed students list.\n"
+ "Parameters: index/INDEX or email/EMAIL or id/STUDENT ID\n"
+ "Example: " + COMMAND_WORD + " email/johndoe@gmail.com";

public static final String MESSAGE_DELETE_PERSON_SUCCESS = "Deleted Student: %1$s";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.util.Set;
import java.util.stream.Stream;

import seedu.address.logic.commands.AddCommand;
import seedu.address.logic.commands.AddStudentCommand;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.person.Email;
import seedu.address.model.person.Name;
Expand All @@ -20,20 +20,20 @@
/**
* Parses input arguments and creates a new AddCommand object
*/
public class AddCommandParser implements Parser<AddCommand> {
public class AddStudentCommandParser implements Parser<AddStudentCommand> {

/**
* Parses the given {@code String} of arguments in the context of the AddCommand
* and returns an AddCommand object for execution.
* @throws ParseException if the user input does not conform the expected format
*/
public AddCommand parse(String args) throws ParseException {
public AddStudentCommand parse(String args) throws ParseException {
ArgumentMultimap argMultimap =
ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_EMAIL, PREFIX_STUDENTID, PREFIX_TAG);

if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_EMAIL, PREFIX_STUDENTID)
|| !argMultimap.getPreamble().isEmpty()) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE));
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddStudentCommand.MESSAGE_USAGE));
}

argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_STUDENTID, PREFIX_EMAIL);
Expand All @@ -44,7 +44,7 @@ public AddCommand parse(String args) throws ParseException {

Person person = new Person(name, email, studentId, tagList);

return new AddCommand(person);
return new AddStudentCommand(person);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import seedu.address.commons.core.LogsCenter;
import seedu.address.logic.commands.AddClassCommand;
import seedu.address.logic.commands.AddCommand;
import seedu.address.logic.commands.AddStudentCommand;
import seedu.address.logic.commands.ClearCommand;
import seedu.address.logic.commands.Command;
import seedu.address.logic.commands.DeleteClassCommand;
Expand Down Expand Up @@ -59,8 +59,8 @@ public Command parseCommand(String userInput) throws ParseException {

switch (commandWord) {

case AddCommand.COMMAND_WORD:
return new AddCommandParser().parse(arguments);
case AddStudentCommand.COMMAND_WORD:
return new AddStudentCommandParser().parse(arguments);

case EditCommand.COMMAND_WORD:
return new EditCommandParser().parse(arguments);
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://ay2324s2-cs2103t-t09-4.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
4 changes: 2 additions & 2 deletions src/test/java/seedu/address/logic/LogicManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import org.junit.jupiter.api.io.TempDir;

import seedu.address.commons.core.GuiSettings;
import seedu.address.logic.commands.AddCommand;
import seedu.address.logic.commands.AddStudentCommand;
import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.ListStudentsCommand;
import seedu.address.logic.commands.exceptions.CommandException;
Expand Down Expand Up @@ -168,7 +168,7 @@ public void saveAddressBook(ReadOnlyAddressBook addressBook, Path filePath)
logic = new LogicManager(model, storage);

// Triggers the saveAddressBook method by executing an add command
String addCommand = AddCommand.COMMAND_WORD + NAME_DESC_AMY
String addCommand = AddStudentCommand.COMMAND_WORD + NAME_DESC_AMY
+ EMAIL_DESC_AMY + STUDENT_ID_DESC_AMY;
Person expectedPerson = new PersonBuilder(AMY).withTags().build();
ModelManager expectedModel = new ModelManager();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* Contains integration tests (interaction with the Model) for {@code AddCommand}.
*/
public class AddCommandIntegrationTest {
public class AddStudentCommandIntegrationTest {

private Model model;

Expand All @@ -33,16 +33,16 @@ public void execute_newPerson_success() {
Model expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs());
expectedModel.addPerson(validPerson);

assertCommandSuccess(new AddCommand(validPerson), model,
String.format(AddCommand.MESSAGE_SUCCESS, Messages.format(validPerson)),
assertCommandSuccess(new AddStudentCommand(validPerson), model,
String.format(AddStudentCommand.MESSAGE_SUCCESS, Messages.format(validPerson)),
expectedModel);
}

@Test
public void execute_duplicatePerson_throwsCommandException() {
Person personInList = model.getAddressBook().getPersonList().get(0);
assertCommandFailure(new AddCommand(personInList), model,
AddCommand.MESSAGE_DUPLICATE_PERSON);
assertCommandFailure(new AddStudentCommand(personInList), model,
AddStudentCommand.MESSAGE_DUPLICATE_PERSON);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,46 +31,47 @@
* Contains integration tests (interaction with the Model) for
* {@code AddCommand}.
*/
public class AddCommandTest {
public class AddStudentCommandTest {

@Test
public void constructor_nullPerson_throwsNullPointerException() {
assertThrows(NullPointerException.class, () -> new AddCommand(null));
assertThrows(NullPointerException.class, () -> new AddStudentCommand(null));
}

@Test
public void execute_personAcceptedByModel_addSuccessful() throws Exception {
ModelStubAcceptingPersonAdded modelStub = new ModelStubAcceptingPersonAdded();
Person validPerson = new PersonBuilder().build();

CommandResult commandResult = new AddCommand(validPerson).execute(modelStub);
CommandResult commandResult = new AddStudentCommand(validPerson).execute(modelStub);

assertEquals(String.format(AddCommand.MESSAGE_SUCCESS, Messages.format(validPerson)),
assertEquals(String.format(AddStudentCommand.MESSAGE_SUCCESS, Messages.format(validPerson)),
commandResult.getFeedbackToUser());
assertEquals(Arrays.asList(validPerson), modelStub.personsAdded);
}

@Test
public void execute_duplicatePerson_throwsCommandException() {
Person validPerson = new PersonBuilder().build();
AddCommand addCommand = new AddCommand(validPerson);
AddStudentCommand addCommand = new AddStudentCommand(validPerson);
ModelStub modelStub = new ModelStubWithPerson(validPerson);

assertThrows(CommandException.class, AddCommand.MESSAGE_DUPLICATE_PERSON, () -> addCommand.execute(modelStub));
assertThrows(CommandException.class, AddStudentCommand.MESSAGE_DUPLICATE_PERSON, (
) -> addCommand.execute(modelStub));
}

@Test
public void equals() {
Person alice = new PersonBuilder().withName("Alice").build();
Person bob = new PersonBuilder().withName("Bob").build();
AddCommand addAliceCommand = new AddCommand(alice);
AddCommand addBobCommand = new AddCommand(bob);
AddStudentCommand addAliceCommand = new AddStudentCommand(alice);
AddStudentCommand addBobCommand = new AddStudentCommand(bob);

// same object -> returns true
assertTrue(addAliceCommand.equals(addAliceCommand));

// same values -> returns true
AddCommand addAliceCommandCopy = new AddCommand(alice);
AddStudentCommand addAliceCommandCopy = new AddStudentCommand(alice);
assertTrue(addAliceCommand.equals(addAliceCommandCopy));

// different types -> returns false
Expand All @@ -85,8 +86,8 @@ public void equals() {

@Test
public void toStringMethod() {
AddCommand addCommand = new AddCommand(ALICE);
String expected = AddCommand.class.getCanonicalName() + "{toAdd=" + ALICE + "}";
AddStudentCommand addCommand = new AddStudentCommand(ALICE);
String expected = AddStudentCommand.class.getCanonicalName() + "{toAdd=" + ALICE + "}";
assertEquals(expected, addCommand.toString());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.junit.jupiter.api.Test;

import seedu.address.logic.Messages;
import seedu.address.logic.commands.AddCommand;
import seedu.address.logic.commands.AddStudentCommand;
import seedu.address.model.person.Email;
import seedu.address.model.person.Name;
import seedu.address.model.person.Person;
Expand All @@ -43,16 +43,16 @@
/**
* Contains unit tests for AddCommandParser.
*/
public class AddCommandParserTest {
private AddCommandParser parser = new AddCommandParser();
public class AddStudentCommandParserTest {
private AddStudentCommandParser parser = new AddStudentCommandParser();

@Test
public void parse_allFieldsPresent_success() {
Person expectedPerson = new PersonBuilder(BOB).withTags(VALID_TAG_FRIEND).build();

// whitespace only preamble
assertParseSuccess(parser, PREAMBLE_WHITESPACE + NAME_DESC_BOB + EMAIL_DESC_BOB + STUDENT_ID_DESC_BOB
+ TAG_DESC_FRIEND, new AddCommand(expectedPerson));
+ TAG_DESC_FRIEND, new AddStudentCommand(expectedPerson));


// multiple tags - all accepted
Expand All @@ -61,7 +61,7 @@ public void parse_allFieldsPresent_success() {
assertParseSuccess(parser,
NAME_DESC_BOB + EMAIL_DESC_BOB + STUDENT_ID_DESC_BOB
+ TAG_DESC_HUSBAND + TAG_DESC_FRIEND,
new AddCommand(expectedPersonMultipleTags));
new AddStudentCommand(expectedPersonMultipleTags));
}

@Test
Expand Down Expand Up @@ -122,12 +122,12 @@ public void parse_optionalFieldsMissing_success() {
// zero tags
Person expectedPerson = new PersonBuilder(AMY).withTags().build();
assertParseSuccess(parser, NAME_DESC_AMY + EMAIL_DESC_AMY + STUDENT_ID_DESC_AMY,
new AddCommand(expectedPerson));
new AddStudentCommand(expectedPerson));
}

@Test
public void parse_compulsoryFieldMissing_failure() {
String expectedMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE);
String expectedMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddStudentCommand.MESSAGE_USAGE);

// missing name prefix
assertParseFailure(parser, VALID_NAME_BOB + EMAIL_DESC_BOB + STUDENT_ID_DESC_BOB,
Expand Down Expand Up @@ -172,6 +172,6 @@ public void parse_invalidValue_failure() {
// non-empty preamble
assertParseFailure(parser, PREAMBLE_NON_EMPTY + NAME_DESC_BOB + EMAIL_DESC_BOB + STUDENT_ID_DESC_BOB
+ TAG_DESC_FRIEND,
String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE));
String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddStudentCommand.MESSAGE_USAGE));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import seedu.address.commons.core.index.Index;
import seedu.address.logic.commands.AddClassCommand;
import seedu.address.logic.commands.AddCommand;
import seedu.address.logic.commands.AddStudentCommand;
import seedu.address.logic.commands.ClearCommand;
import seedu.address.logic.commands.DeleteClassCommand;
import seedu.address.logic.commands.DeleteCommand;
Expand Down Expand Up @@ -53,8 +53,8 @@ public class AddressBookParserTest {
@Test
public void parseCommand_add() throws Exception {
Person person = new PersonBuilder().build();
AddCommand command = (AddCommand) parser.parseCommand(PersonUtil.getAddCommand(person));
assertEquals(new AddCommand(person), command);
AddStudentCommand command = (AddStudentCommand) parser.parseCommand(PersonUtil.getAddCommand(person));
assertEquals(new AddStudentCommand(person), command);
}

@Test
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/seedu/address/testutil/PersonUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import java.util.Set;

import seedu.address.logic.commands.AddCommand;
import seedu.address.logic.commands.AddStudentCommand;
import seedu.address.logic.commands.EditCommand.EditPersonDescriptor;
import seedu.address.model.person.Person;
import seedu.address.model.tag.Tag;
Expand All @@ -21,7 +21,7 @@ public class PersonUtil {
* Returns an add command string for adding the {@code person}.
*/
public static String getAddCommand(Person person) {
return AddCommand.COMMAND_WORD + " " + getPersonDetails(person);
return AddStudentCommand.COMMAND_WORD + " " + getPersonDetails(person);
}

/**
Expand Down

0 comments on commit 28ddf76

Please sign in to comment.