forked from AY2324S2-CS2103T-T09-4/tp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into View-team
# Conflicts: # src/main/java/seedu/address/logic/parser/AddressBookParser.java # src/main/resources/images/damith1.png # src/main/resources/images/damith2.png # src/main/resources/images/damith3.png # src/main/resources/view/MainWindow.fxml
- Loading branch information
Showing
15 changed files
with
680 additions
and
67 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
@startuml | ||
!include style.puml | ||
skinparam ArrowFontStyle plain | ||
!define input "/add_student name/john email/[email protected] id/A1234567L" | ||
|
||
|
||
box Logic LOGIC_COLOR_T1 | ||
participant ":LogicManager" as LogicManager LOGIC_COLOR | ||
participant ":AddressBookParser" as AddressBookParser LOGIC_COLOR | ||
participant ":AddStudentCommandParser" as AddStudentCommandParser LOGIC_COLOR | ||
participant "d:AddStudentCommand" as AddStudentCommand LOGIC_COLOR | ||
participant "r:CommandResult" as CommandResult LOGIC_COLOR | ||
end box | ||
|
||
box Model MODEL_COLOR_T1 | ||
participant "m:Model" as Model MODEL_COLOR | ||
end box | ||
|
||
[-> LogicManager : execute(input) | ||
activate LogicManager | ||
|
||
LogicManager -> AddressBookParser : parseCommand(input) | ||
activate AddressBookParser | ||
|
||
create AddStudentCommandParser | ||
AddressBookParser -> AddStudentCommandParser | ||
activate AddStudentCommandParser | ||
|
||
AddStudentCommandParser --> AddressBookParser | ||
deactivate AddStudentCommandParser | ||
|
||
AddressBookParser -> AddStudentCommandParser : parse("name/john email/[email protected] id/A1234567L") | ||
activate AddStudentCommandParser | ||
|
||
create AddStudentCommand | ||
AddStudentCommandParser -> AddStudentCommand | ||
activate AddStudentCommand | ||
|
||
AddStudentCommand --> AddStudentCommandParser | ||
deactivate AddStudentCommand | ||
|
||
AddStudentCommandParser --> AddressBookParser : d(p) | ||
deactivate AddStudentCommandParser | ||
|
||
AddressBookParser --> LogicManager : d(p) | ||
deactivate AddressBookParser | ||
|
||
LogicManager -> AddStudentCommand : execute(m) | ||
activate AddStudentCommand | ||
|
||
AddStudentCommand -> Model : addPerson(p) | ||
activate Model | ||
|
||
Model --> AddStudentCommand | ||
deactivate Model | ||
|
||
create CommandResult | ||
AddStudentCommand -> CommandResult | ||
activate CommandResult | ||
|
||
CommandResult --> AddStudentCommand | ||
deactivate CommandResult | ||
|
||
AddStudentCommand --> LogicManager : r | ||
deactivate AddStudentCommand | ||
|
||
[<--LogicManager | ||
deactivate LogicManager | ||
|
||
@enduml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
@startuml | ||
!include style.puml | ||
skinparam ArrowFontStyle plain | ||
|
||
box Logic LOGIC_COLOR_T1 | ||
participant ":LogicManager" as LogicManager LOGIC_COLOR | ||
participant ":AddressBookParser" as AddressBookParser LOGIC_COLOR | ||
participant ":AddStudentToClassCommandParser" as AddStudentToClassCommandParser LOGIC_COLOR | ||
participant "s:AddStudentToClassByIdCommand" as AddStudentToClassByIdCommand LOGIC_COLOR | ||
participant "r:CommandResult" as CommandResult LOGIC_COLOR | ||
end box | ||
|
||
box Model MODEL_COLOR_T1 | ||
participant "m:Model" as Model MODEL_COLOR | ||
end box | ||
|
||
[-> LogicManager : execute(addStudent) | ||
activate LogicManager | ||
|
||
LogicManager -> AddressBookParser : parseCommand(addStudent) | ||
activate AddressBookParser | ||
|
||
create AddStudentToClassCommandParser | ||
AddressBookParser -> AddStudentToClassCommandParser | ||
activate AddStudentToClassCommandParser | ||
|
||
AddStudentToClassCommandParser --> AddressBookParser | ||
deactivate AddStudentToClassCommandParser | ||
|
||
AddressBookParser -> AddStudentToClassCommandParser : parse(studentId, module, tutorial) | ||
activate AddStudentToClassCommandParser | ||
|
||
create AddStudentToClassByIdCommand | ||
AddStudentToClassCommandParser -> AddStudentToClassByIdCommand | ||
activate AddStudentToClassByIdCommand | ||
|
||
AddStudentToClassByIdCommand --> AddStudentToClassCommandParser : | ||
deactivate AddStudentToClassByIdCommand | ||
|
||
AddStudentToClassCommandParser --> AddressBookParser : s | ||
deactivate AddStudentToClassCommandParser | ||
'Hidden arrow to position the destroy marker below the end of the activation bar. | ||
AddStudentToClassCommandParser -[hidden]-> AddressBookParser | ||
destroy AddStudentToClassCommandParser | ||
|
||
AddressBookParser --> LogicManager : s | ||
deactivate AddressBookParser | ||
|
||
LogicManager -> AddStudentToClassByIdCommand : execute(m) | ||
activate AddStudentToClassByIdCommand | ||
|
||
AddStudentToClassByIdCommand -> Model : searchPersonByPredicate() | ||
activate Model | ||
|
||
Model --> AddStudentToClassByIdCommand : p | ||
deactivate Model | ||
|
||
AddStudentToClassByIdCommand -> Model : addPersonToTutorialClass(p) | ||
activate Model | ||
|
||
Model --> AddStudentToClassByIdCommand | ||
deactivate Model | ||
|
||
create CommandResult | ||
AddStudentToClassByIdCommand -> CommandResult | ||
activate CommandResult | ||
|
||
CommandResult --> AddStudentToClassByIdCommand | ||
deactivate CommandResult | ||
|
||
AddStudentToClassByIdCommand --> LogicManager : r | ||
deactivate AddStudentToClassByIdCommand | ||
|
||
[<--LogicManager | ||
deactivate LogicManager | ||
|
||
@enduml |
72 changes: 72 additions & 0 deletions
72
src/main/java/seedu/address/logic/commands/ListStudentsOfClassCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_MODULECODE; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_TUTORIALCLASS; | ||
|
||
import seedu.address.logic.commands.exceptions.CommandException; | ||
import seedu.address.model.Model; | ||
import seedu.address.model.module.ModuleCode; | ||
import seedu.address.model.module.TutorialClass; | ||
|
||
/** | ||
* A command to list all students of a particular tutorial class. | ||
*/ | ||
public class ListStudentsOfClassCommand extends Command { | ||
|
||
public static final String COMMAND_WORD = "/class_list_students"; | ||
public static final String MESSAGE_STUDENT_LIST_EMPTY = "No students found in the specified tutorial class"; | ||
public static final String MESSAGE_USAGE = COMMAND_WORD + ": List students of the tutorial class. \n" | ||
+ "Parameters: " | ||
+ PREFIX_MODULECODE + "MODULE CODE " | ||
+ PREFIX_TUTORIALCLASS + "TUTORIAL CLASS " | ||
+ "Example: " + COMMAND_WORD + " " | ||
+ PREFIX_MODULECODE + "CS2103T " | ||
+ PREFIX_TUTORIALCLASS + "T09 "; | ||
|
||
private final ModuleCode module; | ||
private final TutorialClass tutorialClass; | ||
|
||
/** | ||
* Creates a ListStudentsCommand to list students of the specified tutorial class. | ||
* | ||
* @param module The module code. | ||
* @param tutorialClass The tutorial class. | ||
*/ | ||
public ListStudentsOfClassCommand(ModuleCode module, TutorialClass tutorialClass) { | ||
requireNonNull(module); | ||
this.module = module; | ||
this.tutorialClass = tutorialClass; | ||
} | ||
@Override | ||
public CommandResult execute(Model model) throws CommandException { | ||
requireNonNull(model); | ||
ModuleCode existingModule = model.findModuleFromList(module); | ||
if (existingModule == null || !existingModule.hasTutorialClass(tutorialClass)) { | ||
return new CommandResult(String.format("Module %s or tutorial class %s not found", | ||
module, tutorialClass, MESSAGE_STUDENT_LIST_EMPTY)); | ||
} | ||
TutorialClass existingTutorialClass = model.findTutorialClassFromList(tutorialClass, module); | ||
if (existingTutorialClass.getStudents().isEmpty()) { | ||
return new CommandResult(MESSAGE_STUDENT_LIST_EMPTY); | ||
} | ||
|
||
StringBuilder result = new StringBuilder(); | ||
result.append("Module: ").append(module).append(", Tutorial Class: ") | ||
.append(tutorialClass).append("\nStudents: "); | ||
existingTutorialClass.getStudents().forEach(student -> result.append(student.getName()).append(", ")); | ||
return new CommandResult(result.toString().trim()); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
if (other == this) { | ||
return true; | ||
} | ||
if (!(other instanceof ListStudentsOfClassCommand)) { | ||
return false; | ||
} | ||
ListStudentsOfClassCommand command = (ListStudentsOfClassCommand) other; | ||
return module.equals(command.module) && tutorialClass.equals(command.tutorialClass); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/main/java/seedu/address/logic/parser/ListStudentsOfClassCommandParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package seedu.address.logic.parser; | ||
|
||
|
||
import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_MODULECODE; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_TUTORIALCLASS; | ||
|
||
import java.util.stream.Stream; | ||
|
||
import seedu.address.logic.commands.ListStudentsOfClassCommand; | ||
import seedu.address.logic.parser.exceptions.ParseException; | ||
import seedu.address.model.module.ModuleCode; | ||
import seedu.address.model.module.TutorialClass; | ||
|
||
|
||
/** | ||
* Parses input arguments and creates a new ListStudentsCommand object. | ||
*/ | ||
public class ListStudentsOfClassCommandParser implements Parser<ListStudentsOfClassCommand> { | ||
|
||
/** | ||
* Parses the given {@code String} of arguments in the context of the ListStudentsCommand | ||
* and returns a ListStudentsCommand object for execution. | ||
* | ||
* @param args String containing the arguments. | ||
* @return ListStudentsCommand object representing the command. | ||
* @throws ParseException if the user input does not conform to the expected format. | ||
*/ | ||
public ListStudentsOfClassCommand parse(String args) throws ParseException { | ||
ArgumentMultimap argMultimap = | ||
ArgumentTokenizer.tokenize(args, PREFIX_MODULECODE, PREFIX_TUTORIALCLASS); | ||
|
||
if (!arePrefixesPresent(argMultimap, PREFIX_MODULECODE, PREFIX_TUTORIALCLASS) | ||
|| !argMultimap.getPreamble().isEmpty()) { | ||
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, | ||
ListStudentsOfClassCommand.MESSAGE_USAGE)); | ||
} | ||
|
||
argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_MODULECODE, PREFIX_TUTORIALCLASS); | ||
ModuleCode module = ParserUtil.parseModuleCode(argMultimap.getValue(PREFIX_MODULECODE).get()); | ||
TutorialClass tutorialClass = ParserUtil.parseTutorialClass(argMultimap.getValue(PREFIX_TUTORIALCLASS).get()); | ||
|
||
return new ListStudentsOfClassCommand(module, tutorialClass); | ||
} | ||
|
||
/** | ||
* Returns true if all the prefixes contain non-empty values in the given {@code ArgumentMultimap}. | ||
*/ | ||
private static boolean arePrefixesPresent(ArgumentMultimap argumentMultimap, Prefix... prefixes) { | ||
return Stream.of(prefixes).allMatch(prefix -> argumentMultimap.getValue(prefix).isPresent()); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.