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

[T4A2][T17-B3]Sin Yu Fan #1691

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
13 changes: 13 additions & 0 deletions src/seedu/addressbook/data/person/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public class Person implements ReadOnlyPerson {
private Phone phone;
private Email email;
private Address address;

private int sequenceNumber;
public static int nextSequenceNumber = 1;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nextSequenceNumber should be private


private final UniqueTagList tags;
/**
Expand All @@ -25,6 +28,8 @@ public Person(Name name, Phone phone, Email email, Address address, UniqueTagLis
this.email = email;
this.address = address;
this.tags = new UniqueTagList(tags); // protect internal tags from changes in the arg list

this.setSequenceNumber(nextSequenceNumber++);
}

/**
Expand Down Expand Up @@ -84,4 +89,12 @@ public String toString() {
return getAsTextShowAll();
}

public int getSequenceNumber() {
return sequenceNumber;
}

public void setSequenceNumber(int sequenceNumber) {
this.sequenceNumber = sequenceNumber;
}

}
14 changes: 7 additions & 7 deletions src/seedu/addressbook/parser/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public Parser() {}
* @param userInput full user input string
* @return the command based on the user input
*/
public Command parseCommand(String userInput) {
public static Command parseCommand(String userInput) {
final Matcher matcher = BASIC_COMMAND_FORMAT.matcher(userInput.trim());
if (!matcher.matches()) {
return new IncorrectCommand(String.format(MESSAGE_INVALID_COMMAND_FORMAT, HelpCommand.MESSAGE_USAGE));
Expand Down Expand Up @@ -96,7 +96,7 @@ public Command parseCommand(String userInput) {
* @param args full command args string
* @return the prepared command
*/
private Command prepareAdd(String args){
private static Command prepareAdd(String args){
final Matcher matcher = PERSON_DATA_ARGS_FORMAT.matcher(args.trim());
// Validate arg string format
if (!matcher.matches()) {
Expand Down Expand Up @@ -150,7 +150,7 @@ private static Set<String> getTagsFromArgs(String tagArguments) throws IllegalVa
* @param args full command args string
* @return the prepared command
*/
private Command prepareDelete(String args) {
private static Command prepareDelete(String args) {
try {
final int targetIndex = parseArgsAsDisplayedIndex(args);
return new DeleteCommand(targetIndex);
Expand All @@ -167,7 +167,7 @@ private Command prepareDelete(String args) {
* @param args full command args string
* @return the prepared command
*/
private Command prepareView(String args) {
private static Command prepareView(String args) {

try {
final int targetIndex = parseArgsAsDisplayedIndex(args);
Expand All @@ -186,7 +186,7 @@ private Command prepareView(String args) {
* @param args full command args string
* @return the prepared command
*/
private Command prepareViewAll(String args) {
private static Command prepareViewAll(String args) {

try {
final int targetIndex = parseArgsAsDisplayedIndex(args);
Expand All @@ -207,7 +207,7 @@ private Command prepareViewAll(String args) {
* @throws ParseException if no region of the args string could be found for the index
* @throws NumberFormatException the args string region is not a valid number
*/
private int parseArgsAsDisplayedIndex(String args) throws ParseException, NumberFormatException {
private static int parseArgsAsDisplayedIndex(String args) throws ParseException, NumberFormatException {
final Matcher matcher = PERSON_INDEX_ARGS_FORMAT.matcher(args.trim());
if (!matcher.matches()) {
throw new ParseException("Could not find index number to parse");
Expand All @@ -222,7 +222,7 @@ private int parseArgsAsDisplayedIndex(String args) throws ParseException, Number
* @param args full command args string
* @return the prepared command
*/
private Command prepareFind(String args) {
private static Command prepareFind(String args) {
final Matcher matcher = KEYWORDS_ARGS_FORMAT.matcher(args.trim());
if (!matcher.matches()) {
return new IncorrectCommand(String.format(MESSAGE_INVALID_COMMAND_FORMAT,
Expand Down