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

Trying the pull request #29

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
42 changes: 34 additions & 8 deletions src/seedu/addressbook/AddressBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,32 @@ private static void showToUser(String... message) {
System.out.println(LINE_PREFIX + m);
}
}
//Without Varargs
/*private static void showToUser(String message) {
System.out.println(LINE_PREFIX + message);
}
private static void showToUser(String message, String message2) {
System.out.println(LINE_PREFIX + message);
System.out.println(LINE_PREFIX + message2);
}
private static void showToUser(String message, String message2,String message3) {
System.out.println(LINE_PREFIX + message);
System.out.println(LINE_PREFIX + message2);
System.out.println(LINE_PREFIX + message3);
}
private static void showToUser(String message, String message2,String message3,String message4) {
System.out.println(LINE_PREFIX + message);
System.out.println(LINE_PREFIX + message2);
System.out.println(LINE_PREFIX + message3);
System.out.println(LINE_PREFIX + message4);
}
private static void showToUser(String message, String message2,String message3,String message4, String message5) {
System.out.println(LINE_PREFIX + message);
System.out.println(LINE_PREFIX + message2);
System.out.println(LINE_PREFIX + message3);
System.out.println(LINE_PREFIX + message4);
System.out.println(LINE_PREFIX + message5);
}*/

/**
* Shows the list of persons to the user.
Expand Down Expand Up @@ -989,12 +1015,12 @@ private static String extractPhoneFromPersonString(String encoded) {

// phone is last arg, target is from prefix to end of string
if (indexOfPhonePrefix > indexOfEmailPrefix) {
return removePrefixSign(encoded.substring(indexOfPhonePrefix, encoded.length()).trim(),
return removePrefix(encoded.substring(indexOfPhonePrefix, encoded.length()).trim(),
PERSON_DATA_PREFIX_PHONE);

// phone is middle arg, target is from own prefix to next prefix
} else {
return removePrefixSign(
return removePrefix(
encoded.substring(indexOfPhonePrefix, indexOfEmailPrefix).trim(),
PERSON_DATA_PREFIX_PHONE);
}
Expand All @@ -1012,12 +1038,12 @@ private static String extractEmailFromPersonString(String encoded) {

// email is last arg, target is from prefix to end of string
if (indexOfEmailPrefix > indexOfPhonePrefix) {
return removePrefixSign(encoded.substring(indexOfEmailPrefix, encoded.length()).trim(),
return removePrefix(encoded.substring(indexOfEmailPrefix, encoded.length()).trim(),
PERSON_DATA_PREFIX_EMAIL);

// email is middle arg, target is from own prefix to next prefix
} else {
return removePrefixSign(
return removePrefix(
encoded.substring(indexOfEmailPrefix, indexOfPhonePrefix).trim(),
PERSON_DATA_PREFIX_EMAIL);
}
Expand Down Expand Up @@ -1146,12 +1172,12 @@ private static String getUsageInfoForExitCommand() {
/**
* Removes sign(p/, d/, etc) from parameter string
*
* @param s Parameter as a string
* @param sign Parameter sign to be removed
* @param fullstring Parameter as a string
* @param prefix Parameter sign to be removed
* @return string without the sign
*/
private static String removePrefixSign(String s, String sign) {
return s.replace(sign, "");
private static String removePrefix(String fullstring, String prefix) {
return fullstring.replace(prefix, "");
}

/**
Expand Down