forked from nus-cs2103-AY2122S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from g4ryy/add-teacher-features
Add teacher features
- Loading branch information
Showing
78 changed files
with
3,020 additions
and
794 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,10 +1,16 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_GENDER; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_INVOLVEMENT; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; | ||
|
||
import java.util.Set; | ||
|
||
import seedu.address.logic.commands.descriptors.EditPersonDescriptor; | ||
import seedu.address.model.person.Address; | ||
import seedu.address.model.person.Email; | ||
import seedu.address.model.person.Gender; | ||
import seedu.address.model.person.Involvement; | ||
import seedu.address.model.person.Name; | ||
import seedu.address.model.person.Person; | ||
|
@@ -16,10 +22,22 @@ | |
*/ | ||
public abstract class EditCommand extends Command { | ||
|
||
public static final String MESSAGE_EDIT_PERSON_SUCCESS = "Edited Person: %1$s"; | ||
public static final String MESSAGE_DUPLICATE_PERSON = "This %s already exists in the address book."; | ||
public static final String MESSAGE_NOT_EDITED = "At least one field to edit must be provided."; | ||
public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book."; | ||
|
||
protected static final String MESSAGE_USAGE = ": Edits the details of the %s identified " | ||
+ "by the index number used in the displayed person list. " | ||
+ "Existing values will be overwritten by the input values.\n" | ||
+ "Parameters: INDEX (must be a positive integer) " | ||
+ "[" + PREFIX_NAME + "NAME] " | ||
+ "[" + PREFIX_PHONE + "PHONE] " | ||
+ "[" + PREFIX_EMAIL + "EMAIL] " | ||
+ "[" + PREFIX_GENDER + "GENDER] " | ||
+ "[" + PREFIX_INVOLVEMENT + "INVOLVEMENT] "; | ||
|
||
protected static final String EXAMPLE_USAGE = " 1 " | ||
+ PREFIX_PHONE + "91234567 " | ||
+ PREFIX_EMAIL + "[email protected]"; | ||
|
||
/** | ||
* Creates and returns a {@code Person} with the details of {@code personToEdit} | ||
|
@@ -31,10 +49,10 @@ public static Person createEditedPerson(Person personToEdit, EditPersonDescripto | |
Name updatedName = editPersonDescriptor.getName().orElse(personToEdit.getName()); | ||
Phone updatedPhone = editPersonDescriptor.getPhone().orElse(personToEdit.getPhone()); | ||
Email updatedEmail = editPersonDescriptor.getEmail().orElse(personToEdit.getEmail()); | ||
Address updatedAddress = editPersonDescriptor.getAddress().orElse(personToEdit.getAddress()); | ||
Gender updatedGender = editPersonDescriptor.getGender().orElse(personToEdit.getGender()); | ||
Involvement updatedInvolvement = editPersonDescriptor.getInvolvement().orElse(personToEdit.getInvolvement()); | ||
Set<Tag> updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags()); | ||
|
||
return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedInvolvement, updatedTags); | ||
return new Person(updatedName, updatedPhone, updatedEmail, updatedGender, updatedInvolvement, updatedTags); | ||
} | ||
} |
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
57 changes: 57 additions & 0 deletions
57
src/main/java/seedu/address/logic/commands/descriptors/EditTeacherDescriptor.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,57 @@ | ||
package seedu.address.logic.commands.descriptors; | ||
|
||
import java.util.Optional; | ||
|
||
import seedu.address.commons.util.CollectionUtil; | ||
import seedu.address.model.person.OfficeTable; | ||
|
||
/** | ||
* Stores the details to edit the teacher with. Each non-empty field value will replace the | ||
* corresponding field value of the teacher. | ||
*/ | ||
public class EditTeacherDescriptor extends EditPersonDescriptor { | ||
private OfficeTable tableNumber; | ||
|
||
public EditTeacherDescriptor() {} | ||
|
||
/** | ||
* Copy constructor. | ||
* | ||
* @param toCopy {@code EditTeacherDescriptor to copy from} | ||
*/ | ||
public EditTeacherDescriptor(EditTeacherDescriptor toCopy) { | ||
super(toCopy); | ||
setOfficeTable(toCopy.tableNumber); | ||
} | ||
|
||
@Override | ||
public boolean isAnyFieldEdited() { | ||
return super.isAnyFieldEdited() || CollectionUtil.isAnyNonNull(tableNumber); | ||
} | ||
|
||
public void setOfficeTable(OfficeTable tableNumber) { | ||
this.tableNumber = tableNumber; | ||
} | ||
|
||
public Optional<OfficeTable> getOfficeTable() { | ||
return Optional.ofNullable(tableNumber); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
// short circuit if same object | ||
if (other == this) { | ||
return true; | ||
} | ||
|
||
// instanceof handles nulls | ||
if (!(other instanceof EditTeacherDescriptor)) { | ||
return false; | ||
} | ||
|
||
// state check | ||
EditTeacherDescriptor e = (EditTeacherDescriptor) other; | ||
|
||
return super.equals(e) && getOfficeTable().equals(e.getOfficeTable()); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -28,25 +28,25 @@ public class AddStudentCommand extends Command { | |
+ PREFIX_NAME + "NAME " | ||
+ PREFIX_PHONE + "PHONE " | ||
+ PREFIX_EMAIL + "EMAIL " | ||
+ PREFIX_ADDRESS + "ADDRESS " | ||
+ PREFIX_GENDER + "GENDER " | ||
+ PREFIX_ADDRESS + "ADDRESS " | ||
+ PREFIX_FORM_CLASS + "FORM CLASS " | ||
+ PREFIX_EMERGENCY_CONTACT + "EMERGENCY_CONTACT \n" | ||
+ PREFIX_INVOLVEMENT + "INVOLVEMENT " | ||
+ "[" + PREFIX_TAG + "TAG]... " | ||
+ PREFIX_EMERGENCY_CONTACT + "EMERGENCY_CONTACT \n" | ||
+ "Example: " + COMMAND_WORD + " " | ||
+ PREFIX_NAME + "John Doe " | ||
+ PREFIX_PHONE + "98765432 " | ||
+ PREFIX_EMAIL + "[email protected] " | ||
+ PREFIX_ADDRESS + "311, Clementi Ave 2, #02-25 " | ||
+ PREFIX_GENDER + "M " | ||
+ PREFIX_INVOLVEMENT + "Math class " | ||
+ PREFIX_TAG + "naughty " | ||
+ PREFIX_ADDRESS + "311, Clementi Ave 2, #02-25 " | ||
+ PREFIX_FORM_CLASS + "3E1" | ||
+ PREFIX_EMERGENCY_CONTACT + "999 " | ||
+ PREFIX_FORM_CLASS + "3E1"; | ||
+ PREFIX_INVOLVEMENT + "Math class " | ||
+ PREFIX_TAG + "naughty "; | ||
|
||
public static final String MESSAGE_SUCCESS = "New student added: %1$s"; | ||
public static final String MESSAGE_DUPLICATE_PERSON = "This student already exists in the address book"; | ||
public static final String MESSAGE_DUPLICATE_STUDENT = "This student already exists in the address book"; | ||
|
||
private final Student toAdd; | ||
|
||
|
@@ -63,7 +63,7 @@ public CommandResult execute(Model model) throws CommandException { | |
requireNonNull(model); | ||
|
||
if (model.hasPerson(toAdd)) { | ||
throw new CommandException(MESSAGE_DUPLICATE_PERSON); | ||
throw new CommandException(MESSAGE_DUPLICATE_STUDENT); | ||
} | ||
|
||
model.addPerson(toAdd); | ||
|
Oops, something went wrong.