Skip to content

Commit

Permalink
Merge pull request #15 from AY2324S2-CS2103T-T09-4/master
Browse files Browse the repository at this point in the history
Merge
  • Loading branch information
qinxutan authored Mar 20, 2024
2 parents eaefd48 + 6f3de9f commit f7d33a6
Show file tree
Hide file tree
Showing 101 changed files with 1,824 additions and 484 deletions.
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ dependencies {
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'linux'
implementation group: 'org.openjfx', name: 'javafx-swing', version: javaFxVersion, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-swing', version: javaFxVersion, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-swing', version: javaFxVersion, classifier: 'linux'

implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.7.0'
implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: '2.7.4'
Expand Down
1 change: 1 addition & 0 deletions src/main/java/seedu/address/logic/Logic.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@ public interface Logic {
* Set the user prefs' GUI settings.
*/
void setGuiSettings(GuiSettings guiSettings);

boolean isInitialModuleListPanelDisplayed();
}
10 changes: 7 additions & 3 deletions src/main/java/seedu/address/logic/commands/AddClassCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ public class AddClassCommand extends Command {
private final TutorialClass tutorialString;

/**
* @param module of the tutorial class to be added
* Constructs an AddClassCommand to add the specified {@code TutorialClass} to the specified {@code ModuleCode}.
* @param module The module code of the tutorial class to be added.
* @param tutorialClass The tutorial class to be added.
*/
public AddClassCommand(ModuleCode module, TutorialClass tutorialClass) {
requireAllNonNull(module);
Expand Down Expand Up @@ -56,8 +58,10 @@ public CommandResult execute(Model model) throws CommandException {
}

/**
* Generates a command execution success message based on whether the remark is added to or removed from
* {@code personToEdit}.
* Generates a command execution success message based on whether the tutorial class is added successfully.
* @param module The module code of the tutorial class.
* @param tutorialString The tutorial class.
* @return The success message.
*/
private String generateSuccessMessage(ModuleCode module, TutorialClass tutorialString) {
return String.format(MESSAGE_ADD_CLASS_SUCCESS, module.toString(), tutorialString.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ public class DeleteClassCommand extends Command {
private final TutorialClass tutorialString;

/**
* @param module of the tutorial class to be added
* Constructs a DeleteClassCommand to delete the specified {@code TutorialClass}
* from the specified {@code ModuleCode}.
* @param module The module code of the tutorial class to be deleted.
* @param tutorialClass The tutorial class to be deleted.
*/
public DeleteClassCommand(ModuleCode module, TutorialClass tutorialClass) {
requireAllNonNull(module);
Expand Down Expand Up @@ -60,8 +63,10 @@ public CommandResult execute(Model model) throws CommandException {
}

/**
* Generates a command execution success message based on whether the removed from
* {@code personToEdit}.
* Generates a command execution success message based on whether the tutorial class is successfully deleted.
* @param module The module code of the tutorial class.
* @param tutorialString The tutorial class.
* @return The success message.
*/
private String generateSuccessMessage(ModuleCode module, TutorialClass tutorialString) {
return String.format(MESSAGE_DELETE_CLASS_SUCCESS, module.toString(), tutorialString.toString());
Expand Down
58 changes: 0 additions & 58 deletions src/main/java/seedu/address/logic/commands/FindCommand.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
/**
* Lists all persons in the address book to the user.
*/
public class ListCommand extends Command {
public class ListStudentsCommand extends Command {

public static final String COMMAND_WORD = "list";
public static final String COMMAND_WORD = "/list_students";

public static final String MESSAGE_SUCCESS = "Listed all persons";
public static final String MESSAGE_SUCCESS = "Listed all students";


@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class SearchStudentCommand extends Command {
+ "the specified keywords (case-insensitive) and displays them as a list with index numbers.\n"
+ "Only one attribute can be matched per search query.\n"
+ "Partial matches are also displayed.\n"
+ "Parameters: [name/NAME] [id/STUDENT_ID] [email/EMAIL] [module/MODULE_CODE] [tutorial/TUTORIAL_CLASS]\n"
+ "Parameters: [name/NAME] [id/STUDENT_ID] [email/EMAIL]\n"
+ "Example: " + COMMAND_WORD + " id/A012345A";

private final Predicate<Person> predicate;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package seedu.address.logic.commands.addstudenttoclasscommands;

import static java.util.Objects.requireNonNull;

import java.util.function.Predicate;

import seedu.address.logic.Messages;
import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.logic.messages.PersonMessages;
import seedu.address.logic.messages.TutorialClassMessages;
import seedu.address.model.Model;
import seedu.address.model.module.ModuleCode;
import seedu.address.model.module.ModuleTutorialPair;
import seedu.address.model.module.TutorialClass;
import seedu.address.model.person.Email;
import seedu.address.model.person.Person;

/**
* Adds a student to a class by email.
*/
public class AddStudentToClassByEmailCommand extends AddStudentToClassCommand {

private final Predicate<Person> predicate;

private final Email email;

/**
* Adds a student to a class by email.
* @param email
* @param module
* @param tutorialClass
*/
public AddStudentToClassByEmailCommand(Email email, ModuleCode module, TutorialClass tutorialClass) {
super(module, tutorialClass);
this.email = email;
this.predicate = person -> person.getEmail().equals(email);
}

@Override
public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);
ModuleTutorialPair moduleAndTutorialClass = getModuleAndTutorialClass(model);
TutorialClass tutorialClass = moduleAndTutorialClass.getTutorialClass();
ModuleCode module = moduleAndTutorialClass.getModule();
Person personToAdd;

personToAdd = model.searchPersonByPredicate(predicate);
if (personToAdd == null) {
throw new CommandException(String.format(PersonMessages.MESSAGE_PERSON_EMAIL_NOT_FOUND, email));
}
if (tutorialClass.hasStudent(personToAdd)) {
throw new CommandException(
String.format(TutorialClassMessages.MESSAGE_DUPLICATE_STUDENT_IN_CLASS,
Messages.format(personToAdd), tutorialClass));
} else {
model.addPersonToTutorialClass(personToAdd, module, tutorialClass);
return new CommandResult(
String.format(TutorialClassMessages.MESSAGE_ADD_STUDENT_TO_CLASS_SUCCESS,
Messages.format(personToAdd), module, tutorialClass));
}
}

/**
* Returns true if both AddStudentToClassByEmailCommand have the same email.
*/
@Override
public boolean equals(Object other) {
if (other == this) {
return true;
}

if (!(other instanceof AddStudentToClassByEmailCommand)) {
return false;
}

AddStudentToClassByEmailCommand otherAddCommand = (AddStudentToClassByEmailCommand) other;
return email.equals(otherAddCommand.email);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package seedu.address.logic.commands.addstudenttoclasscommands;

import static java.util.Objects.requireNonNull;

import java.util.function.Predicate;

import seedu.address.logic.Messages;
import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.logic.messages.PersonMessages;
import seedu.address.model.Model;
import seedu.address.model.module.ModuleCode;
import seedu.address.model.module.ModuleTutorialPair;
import seedu.address.model.module.TutorialClass;
import seedu.address.model.person.Person;
import seedu.address.model.person.StudentId;

/**
* Adds a student to a class by student id.
*/
public class AddStudentToClassByIdCommand extends AddStudentToClassCommand {

private final Predicate<Person> predicate;

private final StudentId studentId;

/**
* Adds a student to a class by student id.
* @param studentId
* @param module
* @param tutorialClass
*/
public AddStudentToClassByIdCommand(StudentId studentId, ModuleCode module, TutorialClass tutorialClass) {
super(module, tutorialClass);
this.studentId = studentId;
this.predicate = person -> person.getStudentId().equals(studentId);
}

@Override
public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);
ModuleTutorialPair moduleAndTutorialClass = getModuleAndTutorialClass(model);
ModuleCode module = moduleAndTutorialClass.getModule();
TutorialClass tutorialClass = moduleAndTutorialClass.getTutorialClass();
Person personToAdd;
personToAdd = model.searchPersonByPredicate(predicate);
if (personToAdd == null) {
throw new CommandException(String.format(PersonMessages.MESSAGE_PERSON_STUDENT_ID_NOT_FOUND, studentId));
}
if (tutorialClass.hasStudent(personToAdd)) {
throw new CommandException(String.format(PersonMessages.MESSAGE_DUPLICATE_STUDENT_IN_CLASS,
Messages.format(personToAdd), tutorialClass));
} else {
model.addPersonToTutorialClass(personToAdd, module, tutorialClass);
return new CommandResult(String.format(PersonMessages.MESSAGE_ADD_STUDENT_TO_CLASS_SUCCESS,
Messages.format(personToAdd), module, tutorialClass));
}
}

/**
* Returns true if both AddStudentToClassByIdCommand have the same studentId.
*/
@Override
public boolean equals(Object other) {
if (other == this) {
return true;
}

if (!(other instanceof AddStudentToClassByIdCommand)) {
return false;
}

AddStudentToClassByIdCommand otherAddCommand = (AddStudentToClassByIdCommand) other;
return studentId.equals(otherAddCommand.studentId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package seedu.address.logic.commands.addstudenttoclasscommands;

import static java.util.Objects.requireNonNull;

import seedu.address.commons.core.index.Index;
import seedu.address.logic.Messages;
import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.logic.messages.PersonMessages;
import seedu.address.model.Model;
import seedu.address.model.module.ModuleCode;
import seedu.address.model.module.ModuleTutorialPair;
import seedu.address.model.module.TutorialClass;
import seedu.address.model.person.Person;

/**
* Adds a student to a class by index.
*/
public class AddStudentToClassByIndexCommand extends AddStudentToClassCommand {

private final Index targetIndex;

/**
* Adds a student to a class by index.
* @param targetIndex
* @param module
* @param tutorialClass
*/
public AddStudentToClassByIndexCommand(Index targetIndex, ModuleCode module, TutorialClass tutorialClass) {
super(module, tutorialClass);
this.targetIndex = targetIndex;
}

@Override
public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);
ModuleTutorialPair moduleAndTutorialClass = getModuleAndTutorialClass(model);
TutorialClass tutorialClass = moduleAndTutorialClass.getTutorialClass();
ModuleCode module = moduleAndTutorialClass.getModule();
Person personToAdd;
try {
personToAdd = model.getFilteredPersonList().get(targetIndex.getZeroBased());
} catch (IndexOutOfBoundsException e) {
throw new CommandException(
String.format(PersonMessages.MESSAGE_PERSON_INDEX_NOT_FOUND, targetIndex.getOneBased()));
}

if (tutorialClass.hasStudent(personToAdd)) {
throw new CommandException(String.format(PersonMessages.MESSAGE_DUPLICATE_STUDENT_IN_CLASS,
Messages.format(personToAdd), tutorialClass));
} else {
model.addPersonToTutorialClass(personToAdd, module, tutorialClass);
return new CommandResult(
String.format(PersonMessages.MESSAGE_ADD_STUDENT_TO_CLASS_SUCCESS,
Messages.format(personToAdd), module, tutorialClass));
}
}

/**
* Returns true if both AddStudentToClassByIndexCommand have the same index.
*/
@Override
public boolean equals(Object other) {
if (other == this) {
return true;
}

if (!(other instanceof AddStudentToClassByIdCommand)) {
return false;
}

AddStudentToClassByIndexCommand otherAddCommand = (AddStudentToClassByIndexCommand) other;
return targetIndex.equals(otherAddCommand.targetIndex);
}
}
Loading

0 comments on commit f7d33a6

Please sign in to comment.