forked from nus-cs2103-AY2324S2/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.
Add Interviewer type as a Person extension
- Loading branch information
Showing
11 changed files
with
137 additions
and
95 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
64 changes: 64 additions & 0 deletions
64
src/main/java/seedu/address/logic/commands/AddInterviewerCommand.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,64 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
import seedu.address.commons.util.ToStringBuilder; | ||
import seedu.address.logic.Messages; | ||
import seedu.address.logic.commands.exceptions.CommandException; | ||
import seedu.address.model.Model; | ||
import seedu.address.model.person.Person; | ||
|
||
/** | ||
* Adds an interviewer to the talent tracker. | ||
*/ | ||
public class AddInterviewerCommand extends AddCommand { | ||
|
||
public static final String COMMAND_WORD = AddCommand.COMMAND_WORD + "_interviewer"; | ||
|
||
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds an interviewer to the talent tracker. " | ||
+ AddCommand.MESSAGE_USAGE; | ||
|
||
public static final String MESSAGE_SUCCESS = "New interviewer added: %1$s"; | ||
public static final String MESSAGE_DUPLICATE_PERSON = "This interviewer already exists in the talent tracker"; | ||
|
||
/** | ||
* Creates an AddInterviewerCommand to add the specified {@code Person} | ||
*/ | ||
public AddInterviewerCommand(Person person) { | ||
super(person); | ||
} | ||
|
||
@Override | ||
public CommandResult execute(Model model) throws CommandException { | ||
requireNonNull(model); | ||
|
||
if (model.hasPerson(toAdd)) { | ||
throw new CommandException(MESSAGE_DUPLICATE_PERSON); | ||
} | ||
|
||
model.addPerson(toAdd); | ||
return new CommandResult(String.format(MESSAGE_SUCCESS, Messages.format(toAdd))); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
if (other == this) { | ||
return true; | ||
} | ||
|
||
// instanceof handles nulls | ||
if (!(other instanceof AddInterviewerCommand)) { | ||
return false; | ||
} | ||
|
||
AddCommand otherAddCommand = (AddCommand) other; | ||
return toAdd.equals(otherAddCommand.toAdd); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return new ToStringBuilder(this) | ||
.add("toAdd", toAdd) | ||
.toString(); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package seedu.address.model.person; | ||
|
||
import java.util.Set; | ||
|
||
import seedu.address.model.tag.Tag; | ||
|
||
/** | ||
* Represents an Interviewer in the talent tracker. | ||
* Guarantees: details are present and not null, field values are validated, immutable. | ||
*/ | ||
public class Interviewer extends Person { | ||
/** | ||
* Every field must be present and not null. | ||
*/ | ||
public Interviewer(Name name, Phone phone, Email email, Remark remark, Set<Tag> tags) { | ||
super(name, phone, email, remark, tags); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Interviewer: " + super.toString(); | ||
} | ||
} |
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.