Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve checkstyle violations #56

Merged
merged 1 commit into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/main/java/seedu/address/logic/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,12 @@ public static String format(Person person) {
return builder.toString();
}

/**
* Formats the {@code interview} for display to the user.
*/
public static String formatInterview(Interview interview) {
final StringBuilder builder = new StringBuilder();
builder.append("Applicant: ").append(interview.getApplicant().getName())
builder.append("Interview: ").append(interview.getApplicant().getName())
.append(" Interviewer: ")
.append(interview.getInterviewer().getName())
.append(" Date: ")
Expand Down
46 changes: 29 additions & 17 deletions src/main/java/seedu/address/logic/commands/AddInterviewCommand.java
Original file line number Diff line number Diff line change
@@ -1,30 +1,48 @@
package seedu.address.logic.commands;

import static java.util.Objects.requireNonNull;
import static seedu.address.logic.parser.CliSyntax.PREFIX_APPLICANT;
import static seedu.address.logic.parser.CliSyntax.PREFIX_DATE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_DESCRIPTION;
import static seedu.address.logic.parser.CliSyntax.PREFIX_END_TIME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_INTERVIEWER;
import static seedu.address.logic.parser.CliSyntax.PREFIX_START_TIME;

import java.time.LocalDate;
import java.time.LocalTime;
import java.util.List;

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.interview.Interview;
import seedu.address.model.person.Applicant;
import seedu.address.model.person.Interviewer;
import seedu.address.model.person.Person;
import seedu.address.model.person.Phone;

import java.time.LocalDate;
import java.time.LocalTime;
import java.util.List;

/**
* Adds an Interview to the talent tracker.
*/
public class AddInterviewCommand extends Command{
public class AddInterviewCommand extends Command {

public static final String COMMAND_WORD = AddPersonCommand.COMMAND_WORD + "_interview";

public static final String MESSAGE_INFORMATION = "Parameters: "
+ PREFIX_DESCRIPTION + "DESCRIPTION "
+ PREFIX_DATE + "DATE "
+ PREFIX_START_TIME + "START TIME "
+ PREFIX_END_TIME + "END TIME "
+ PREFIX_APPLICANT + "APPLICANT PHONE NUMBER"
+ PREFIX_INTERVIEWER + "INTERVIEWER PHONE NUMBER " + "\n"
+ "Example: " + COMMAND_WORD + " "
+ PREFIX_DESCRIPTION + "technical interview "
+ PREFIX_DATE + "2022-11-11 "
+ PREFIX_START_TIME + "10:00 "
+ PREFIX_END_TIME + "11:00 "
+ PREFIX_APPLICANT + "88888888"
+ PREFIX_INTERVIEWER + "88889999";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds an interview to the talent tracker. "
+ AddPersonCommand.MESSAGE_USAGE;
+ MESSAGE_INFORMATION;


public static final String MESSAGE_SUCCESS = "New Interview added: %1$s";
Expand All @@ -44,7 +62,8 @@ public class AddInterviewCommand extends Command{
/**
* Creates an AddInterviewCommand to add the specified {@code Person}
*/
public AddInterviewCommand(String description, Phone applicant, Phone interviewer, LocalDate date, LocalTime startTime, LocalTime endTime) {
public AddInterviewCommand(String description, Phone applicant, Phone interviewer, LocalDate date,
LocalTime startTime, LocalTime endTime) {
this.description = description;
this.applicant = applicant;
this.interviewer = interviewer;
Expand All @@ -58,7 +77,6 @@ public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);
List<Person> lastShownList = model.getFilteredPersonList();


boolean isFoundApplicant = false;
boolean isFoundInterviewer = false;
Phone targetApplicantPhone = applicant;
Expand All @@ -81,14 +99,9 @@ public CommandResult execute(Model model) throws CommandException {
}
}


if (!isFoundApplicant || !isFoundInterviewer) {
throw new CommandException(Messages.MESSAGE_PERSON_NOT_IN_LIST);
}
// else if (!(applicantSearch instanceof Applicant) || !(interviewerSearch instanceof Interviewer)) {
// throw new CommandException("Phone Number error");
// }


Interview interview = new Interview(applicantSearch, interviewerSearch, date, startTime, endTime, description);

Expand All @@ -113,7 +126,6 @@ public boolean equals(Object other) {
}

AddInterviewCommand otherCommmand = (AddInterviewCommand) other;
// return interview.equals(otherCommmand.interview);
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.interview.Interview;
import seedu.address.model.person.Person;
import seedu.address.model.person.Phone;


/**
* Deletes a person identified using it's displayed index from the address book.
Expand Down Expand Up @@ -46,7 +45,8 @@ public CommandResult execute(Model model) throws CommandException {
}

model.deleteInterview(interview);
return new CommandResult(MESSAGE_DELETE_INTERVIEW_SUCCESS + "\nInformation about delete interview: \n" + Messages.formatInterview(interview));
return new CommandResult(MESSAGE_DELETE_INTERVIEW_SUCCESS
+ "\nInformation about delete interview: \n" + Messages.formatInterview(interview));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public AddApplicantPersonCommand parse(String args) throws ParseException {

if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL)
|| !argMultimap.getPreamble().isEmpty()) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddApplicantPersonCommand.MESSAGE_USAGE));
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT,
AddApplicantPersonCommand.MESSAGE_USAGE));
}

argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
package seedu.address.logic.parser;

import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.logic.parser.CliSyntax.PREFIX_DESCRIPTION;
import static seedu.address.logic.parser.CliSyntax.PREFIX_APPLICANT;
import static seedu.address.logic.parser.CliSyntax.PREFIX_DATE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_START_TIME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_DESCRIPTION;
import static seedu.address.logic.parser.CliSyntax.PREFIX_END_TIME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_APPLICANT;
import static seedu.address.logic.parser.CliSyntax.PREFIX_INTERVIEWER;

import seedu.address.logic.commands.AddInterviewCommand;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.person.Phone;
import static seedu.address.logic.parser.CliSyntax.PREFIX_START_TIME;

import java.time.LocalDate;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.stream.Stream;

import seedu.address.logic.commands.AddInterviewCommand;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.person.Phone;


/**
* Parses input arguments and creates a new AddInterviewCommand object
*/
Expand All @@ -30,9 +31,11 @@ public class AddInterviewCommandParser implements Parser<AddInterviewCommand> {
*/
public AddInterviewCommand parse(String args) throws ParseException {
ArgumentMultimap argMultimap =
ArgumentTokenizer.tokenize(args, PREFIX_DESCRIPTION, PREFIX_DATE, PREFIX_START_TIME, PREFIX_END_TIME, PREFIX_APPLICANT, PREFIX_INTERVIEWER);
ArgumentTokenizer.tokenize(args, PREFIX_DESCRIPTION, PREFIX_DATE, PREFIX_START_TIME, PREFIX_END_TIME,
PREFIX_APPLICANT, PREFIX_INTERVIEWER);

if (!arePrefixesPresent(argMultimap, PREFIX_DESCRIPTION, PREFIX_DATE, PREFIX_START_TIME, PREFIX_END_TIME, PREFIX_APPLICANT, PREFIX_INTERVIEWER)
if (!arePrefixesPresent(argMultimap, PREFIX_DESCRIPTION, PREFIX_DATE, PREFIX_START_TIME, PREFIX_END_TIME,
PREFIX_APPLICANT, PREFIX_INTERVIEWER)
|| !argMultimap.getPreamble().isEmpty()) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddInterviewCommand.MESSAGE_USAGE));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import java.util.Set;
import java.util.stream.Stream;

import seedu.address.logic.commands.AddPersonCommand;
import seedu.address.logic.commands.AddInterviewerPersonCommand;
import seedu.address.logic.commands.AddPersonCommand;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.person.Email;
import seedu.address.model.person.Interviewer;
Expand Down
14 changes: 13 additions & 1 deletion src/main/java/seedu/address/logic/parser/AddressBookParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,19 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import seedu.address.logic.commands.*;
import seedu.address.logic.commands.AddApplicantPersonCommand;
import seedu.address.logic.commands.AddInterviewCommand;
import seedu.address.logic.commands.AddInterviewerPersonCommand;
import seedu.address.logic.commands.ClearCommand;
import seedu.address.logic.commands.Command;
import seedu.address.logic.commands.DeleteCommand;
import seedu.address.logic.commands.DeleteInterviewCommand;
import seedu.address.logic.commands.EditCommand;
import seedu.address.logic.commands.ExitCommand;
import seedu.address.logic.commands.FindCommand;
import seedu.address.logic.commands.HelpCommand;
import seedu.address.logic.commands.ListCommand;
import seedu.address.logic.commands.RemarkCommand;
import seedu.address.logic.parser.exceptions.ParseException;

/**
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/seedu/address/logic/parser/CliSyntax.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ public class CliSyntax {
public static final Prefix PREFIX_EMAIL = new Prefix("e/");
public static final Prefix PREFIX_REMARK = new Prefix("r/");
public static final Prefix PREFIX_TAG = new Prefix("t/");

public static final Prefix PREFIX_DESCRIPTION = new Prefix("desc/");
public static final Prefix PREFIX_DATE = new Prefix("date/");
public static final Prefix PREFIX_START_TIME = new Prefix("st/");
public static final Prefix PREFIX_END_TIME = new Prefix("et/");
public static final Prefix PREFIX_APPLICANT = new Prefix("a/");
public static final Prefix PREFIX_INTERVIEWER = new Prefix("i/");

}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package seedu.address.logic.parser;

import seedu.address.logic.commands.DeleteCommand;
import static seedu.address.logic.Messages.MESSAGE_NOT_INTEGER;

import seedu.address.logic.commands.DeleteInterviewCommand;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.interview.Interview;
import seedu.address.model.person.Phone;

import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.logic.Messages.MESSAGE_NOT_INTEGER;

/**
* Parses input arguments and creates a new DeleteInterviewCommand object
*/
public class DeleteInterviewCommandParser implements Parser<DeleteInterviewCommand> {

/**
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/seedu/address/model/AddressBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,26 @@ public void removePerson(Person key) {

// Interview Operations

/**
* Adds an interview to the address book.
* The interview must not already exist in the address book.
*/
public void addInterview(Interview interview) {
interviews.add(interview);
}

/**
* Returns true if an interview with the same identity as {@code interview} exists in the address book.
*/
public boolean hasInterview(Interview interview) {
requireNonNull(interview);
return interviews.contains(interview);
}

/**
* Removes {@code key} from this {@code AddressBook}.
* {@code key} must exist in the address book.
*/
public void removeInterview(Interview key) {
interviews.remove(key);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/model/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public interface Model {

boolean hasInterview(Interview interview);

void deleteInterview (Interview interview);
void deleteInterview(Interview interview);

ObservableList<Interview> getFilteredInterviewList();
}
17 changes: 14 additions & 3 deletions src/main/java/seedu/address/model/interview/Interview.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package seedu.address.model.interview;

import seedu.address.model.person.Person;

import java.time.LocalDate;
import java.time.LocalTime;

import seedu.address.model.person.Person;

/**
* Represents an Interview in the talent tracker.
*/
public class Interview {
private Person applicant;
private Person interviewer;
Expand All @@ -13,7 +16,11 @@ public class Interview {
private LocalTime endTime;
private String description;

public Interview(Person applicant, Person interviewer, LocalDate date, LocalTime startTime, LocalTime endTime, String description) {
/**
* Represents a Interview in the address book.
*/
public Interview(Person applicant, Person interviewer, LocalDate date, LocalTime startTime,
LocalTime endTime, String description) {
this.applicant = applicant;
this.interviewer = interviewer;
this.date = date;
Expand Down Expand Up @@ -42,6 +49,10 @@ public LocalTime getEndTime() {
return endTime;
}

/**
* Returns true if both interviews of the same name have at least one other identity field that is the same.
* This defines a weaker notion of equality between two interviews.
*/
public boolean isSameInterview(Interview otherInterview) {
boolean applicantMatch = otherInterview.applicant.equals(this.applicant);
boolean interviewerMatch = otherInterview.interviewer.equals(this.interviewer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@

import static java.util.Objects.requireNonNull;
import static seedu.address.commons.util.CollectionUtil.requireAllNonNull;

import java.util.Iterator;
import java.util.List;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import seedu.address.model.interview.exceptions.DuplicateInterviewException;
import seedu.address.model.interview.exceptions.InterviewNotFoundException;

import java.util.Iterator;
import java.util.List;

/**
* A list of interviews that enforces uniqueness between its elements and does not allow nulls.
* An interview is considered unique by comparing using {@code Interview#isSameInterview(Interview)}. As such, adding and updating of
* interviews uses Interview#isSameInterview(Interview) for equality so as to ensure that the interview being added or updated is
* unique in terms of identity in the UniqueInterviewList. However, the removal of an interview uses Interview#equals(Object) so
* An interview is considered unique by comparing using {@code Interview#isSameInterview(Interview)}. As such,
* adding and updating of interviews uses Interview#isSameInterview(Interview) for equality so as to ensure that
* the interview being added or updated is unique in terms of identity in the UniqueInterviewList.
* However, the removal of an interview uses Interview#equals(Object) so
* as to ensure that the interview with exactly the same fields will be removed.
*
* Supports a minimal set of list operations.
Expand All @@ -41,9 +43,9 @@ public boolean contains(Interview toCheck) {
*/
public void add(Interview toAdd) {
requireNonNull(toAdd);
// if (contains(toAdd)) {
// throw new DuplicateInterviewException();
// }
//if (contains(toAdd)) {
// throw new DuplicateInterviewException();
//}
internalList.add(toAdd);
}

Expand All @@ -52,7 +54,8 @@ public void add(Interview toAdd) {
* {@code target} must exist in the list.
* The interview identity of {@code editedInterview} must not be the same as another existing interview in the list.
*/
public void setInterview(Interview target, Interview editedInterview) throws DuplicateInterviewException, InterviewNotFoundException {
public void setInterview(Interview target, Interview editedInterview) throws DuplicateInterviewException,
InterviewNotFoundException {
requireAllNonNull(target, editedInterview);

int index = internalList.indexOf(target);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
package seedu.address.model.interview.exceptions;

/**
* Signals that the operation will result in duplicate Interviews (Interviews are considered duplicates if they have
* the same identity).
*/
public class DuplicateInterviewException extends Throwable {
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
package seedu.address.model.interview.exceptions;

/**
* Signals that the operation is unable to find the specified interview.
*/
public class InterviewNotFoundException extends RuntimeException {
}
Loading