Skip to content

Commit

Permalink
Merge pull request #22 from AY2324S2-CS2103T-T09-4/master
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
qinxutan authored Mar 30, 2024
2 parents b75a097 + 16b38f4 commit 487ca7d
Show file tree
Hide file tree
Showing 16 changed files with 465 additions and 48 deletions.
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.addstudenttoclasscommands.AddStudentToClassCommand;
Expand Down Expand Up @@ -113,12 +114,18 @@ 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);


case AllocateStudentToTeamCommand.COMMAND_WORD:
return new AllocateStudentToTeamCommandParser().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 @@ -43,7 +43,7 @@ public TutorialClassCard(TutorialClass tutorialClass) {
* 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
Binary file added src/main/resources/images/damith1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/images/damith2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/images/damith3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/images/damith4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
108 changes: 66 additions & 42 deletions src/main/resources/view/MainWindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.effect.DropShadow?>

<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.HBox?>
<fx:root type="javafx.stage.Stage" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1"
title="Address App" minWidth="500" minHeight="500" onCloseRequest="#handleExit">
<icons>
Expand All @@ -25,58 +27,80 @@
<URL value="@DarkTheme.css" />
<URL value="@Extensions.css" />
</stylesheets>
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity"
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity"
xmlns="http://javafx.com/javafx/8.0.171"
xmlns:fx="http://javafx.com/fxml/1">
<top>
<MenuBar fx:id="menuBar" VBox.vgrow="ALWAYS">
<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"/>
</Menu>
<Menu mnemonicParsing="false" text="Help">
<MenuItem fx:id="helpMenuItem" mnemonicParsing="false" onAction="#handleHelp" text="Help" />
</Menu>
</MenuBar>
</top>
<center>
<SplitPane dividerPositions="0.33, 0.67">
<items>
<!-- Add a new VBox for the module list panel -->
<VBox fx:id="moduleList" spacing="5"
xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1">
<padding>
<Insets top="10" right="10" bottom="10" left="10" />
</padding>
<!-- Placeholder for the ModuleListPanel -->
<StackPane fx:id="moduleListPanelPlaceholder" maxHeight="Infinity"/>
</VBox>
<VBox fx:id="tutoriallist" spacing="5"
xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1">
<padding>
<Insets top="10" right="10" bottom="10" left="10" />
</padding>
<!-- Placeholder for the TutorialListPanel -->
<StackPane fx:id="tutorialListPanelPlaceholder" maxHeight="Infinity"/>
</VBox>
<VBox fx:id="personList" spacing="5"
xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1">
<padding>
<Insets top="10" right="10" bottom="10" left="10" />
</padding>
<StackPane fx:id="personListPanelPlaceholder" maxHeight="Infinity"/>
</VBox>
</items>
</SplitPane>
</center>
<bottom>
<VBox prefHeight="111.0" prefWidth="604.0" BorderPane.alignment="CENTER">
<children>
<StackPane fx:id="resultDisplayPlaceholder" minHeight="140" prefHeight="140.0"
prefWidth="200.0"/>
<StackPane fx:id="commandBoxPlaceholder" prefHeight="150.0" prefWidth="200.0"/>
</children>
<!-- Horizontal banner -->
<HBox prefHeight="50" prefWidth="400" style="-fx-background-color: derive(#d7cbc0, 20%);"
alignment="CENTER">
<!-- ImageView for the logo or image -->
<ImageView fitWidth="267" fitHeight="150" preserveRatio="true" HBox.hgrow="ALWAYS"
VBox.vgrow="ALWAYS">
<!-- Specify the path or URL for the image -->
<image>
<Image url="/images/damith4.png"/>
</image>
</ImageView>
</HBox>
</children>
</VBox>
</top>
<center>
<SplitPane dividerPositions="0.33, 0.67">
<items>
<!-- Add a new VBox for the module list panel -->
<VBox fx:id="moduleList" spacing="5"
xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1">
<padding>
<Insets top="10" right="10" bottom="10" left="10" />
</padding>
<!-- Placeholder for the ModuleListPanel -->
<StackPane fx:id="moduleListPanelPlaceholder" maxHeight="Infinity"/>
</VBox>
</bottom>
<VBox fx:id="tutoriallist" spacing="5"
xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1">
<padding>
<Insets top="10" right="10" bottom="10" left="10" />
</padding>
<!-- Placeholder for the TutorialListPanel -->
<StackPane fx:id="tutorialListPanelPlaceholder" maxHeight="Infinity"/>
</VBox>
<VBox fx:id="personList" spacing="5"
xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1">
<padding>
<Insets top="10" right="10" bottom="10" left="10" />
</padding>
<StackPane fx:id="personListPanelPlaceholder" maxHeight="Infinity"/>
</VBox>
</items>
</SplitPane>
</center>
<bottom>
<VBox prefHeight="111.0" prefWidth="604.0" BorderPane.alignment="CENTER"
style="-fx-background-color: derive(#d7cbc0, 20%);">
<children>
<StackPane fx:id="resultDisplayPlaceholder" minHeight="140" prefHeight="140.0"
prefWidth="200.0" style="-fx-background-color: #ececec"/>
<StackPane fx:id="commandBoxPlaceholder" prefHeight="150.0" prefWidth="200.0"
style="-fx-background-color: derive(#d7cbc0, 20%);"/>
</children>
<padding>
<Insets bottom="10" />
</padding>
</VBox>
</bottom>
<StackPane fx:id="statusbarPlaceholder" VBox.vgrow="NEVER" />
</BorderPane>
</Scene>
Expand Down
Loading

0 comments on commit 487ca7d

Please sign in to comment.