Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into View-team
Browse files Browse the repository at this point in the history
# 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
qinxutan committed Mar 30, 2024
2 parents 4e95c73 + 487ca7d commit f68b878
Show file tree
Hide file tree
Showing 15 changed files with 680 additions and 67 deletions.
208 changes: 154 additions & 54 deletions docs/DeveloperGuide.md

Large diffs are not rendered by default.

70 changes: 70 additions & 0 deletions docs/diagrams/AddStudentSequence.puml
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
77 changes: 77 additions & 0 deletions docs/diagrams/AddStudentToClassSequence.puml
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
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import seedu.address.logic.commands.HelpCommand;
import seedu.address.logic.commands.ListClassesCommand;
import seedu.address.logic.commands.ListStudentsCommand;
import seedu.address.logic.commands.ListStudentsOfClassCommand;
import seedu.address.logic.commands.SearchStudentCommand;
import seedu.address.logic.commands.SortStudentCommand;
import seedu.address.logic.commands.ViewTeamCommand;
Expand Down Expand Up @@ -114,9 +115,14 @@ public Command parseCommand(String userInput) throws ParseException {
case AddTeamCommand.COMMAND_WORD:
return new AddTeamCommandParser().parse(arguments);


case ListStudentsOfClassCommand.COMMAND_WORD:
return new ListStudentsOfClassCommandParser().parse(arguments);

case SortStudentCommand.COMMAND_WORD:
return new SortStudentCommandParser().parse(arguments);


case DeleteTeamCommand.COMMAND_WORD:
return new DeleteTeamCommandParser().parse(arguments);

Expand Down
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());
}
}

3 changes: 2 additions & 1 deletion src/main/java/seedu/address/model/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import javafx.collections.ObservableList;
import seedu.address.commons.core.GuiSettings;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.module.ModuleCode;
import seedu.address.model.module.TutorialClass;
import seedu.address.model.module.TutorialTeam;
Expand Down Expand Up @@ -89,7 +90,7 @@ public interface Model {
* @param tutorialClass to be searched
* @param moduleCode to be searched
*/
TutorialClass findTutorialClassFromList(TutorialClass tutorialClass, ModuleCode moduleCode);
TutorialClass findTutorialClassFromList(TutorialClass tutorialClass, ModuleCode moduleCode) throws CommandException;

/**
* Deletes the given person.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/ui/ModuleCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public ModuleCard(ModuleCode moduleCode) {
* to enhance visual appearance.
*/
public void updateImage() {
Image moduleImage = new Image("images/group4.png");
Image moduleImage = new Image("images/damith3.png");
circle.setStroke(Color.ROSYBROWN);
circle.setFill(new ImagePattern(moduleImage));
circle.setEffect(new DropShadow(+10d, 0d, +2d, Color.ROSYBROWN));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/ui/PersonCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void updateImage() {
String path = "images/" + person.getName().toString() + ".png";
File file = new File(path);
if (!file.exists()) {
Image defaultImage = new Image("images/student.png");
Image defaultImage = new Image("images/damith1.png");
circle.setStroke(Color.ROSYBROWN);
circle.setFill(new ImagePattern(defaultImage));
circle.setEffect(new DropShadow(+10d, 0d, +2d, Color.ROSYBROWN));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/ui/TutorialClassCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private void updateTeamComboBox(ArrayList<TutorialTeam> teams) {
* to the circle for enhanced visual appearance.
*/
public void updateImage() {
Image moduleImage = new Image("images/class.png");
Image moduleImage = new Image("images/damith2.png");
circle.setStroke(Color.ROSYBROWN);
circle.setFill(new ImagePattern(moduleImage));
circle.setEffect(new DropShadow(+10d, 0d, +2d, Color.ROSYBROWN));
Expand Down
14 changes: 7 additions & 7 deletions src/main/resources/view/MainWindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity"
xmlns="http://javafx.com/javafx/8.0.171"
xmlns:fx="http://javafx.com/fxml/1">
<top>
<VBox minWidth="100.0" prefHeight="100.0" prefWidth="400.0"
xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1">
<children>
<top>
<VBox minWidth="100.0" prefHeight="100.0" prefWidth="400.0"
xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1">
<children>
<MenuBar fx:id="menuBar" prefWidth="400" prefHeight="50" >
<Menu mnemonicParsing="false" text="File">
<MenuItem mnemonicParsing="false" onAction="#handleExit" text="Exit"/>
Expand All @@ -50,7 +50,7 @@
VBox.vgrow="ALWAYS">
<!-- Specify the path or URL for the image -->
<image>
<Image url="/images/logo.png"/>
<Image url="/images/damith4.png"/>
</image>
</ImageView>
</HBox>
Expand Down Expand Up @@ -99,8 +99,8 @@
<padding>
<Insets bottom="10" />
</padding>
</VBox>
</bottom>
</VBox>
</bottom>
<StackPane fx:id="statusbarPlaceholder" VBox.vgrow="NEVER" />
</BorderPane>
</Scene>
Expand Down
Loading

0 comments on commit f68b878

Please sign in to comment.