From 052f55f07d26be84b67a96c7f45d7cca4fdbc2e4 Mon Sep 17 00:00:00 2001 From: "LAPTOP-80LTHV2A\\Hypertun" Date: Tue, 30 Jan 2018 22:05:58 +0800 Subject: [PATCH 1/3] HomeWork --- src/seedu/addressbook/AddressBook.java | 28 +++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/seedu/addressbook/AddressBook.java b/src/seedu/addressbook/AddressBook.java index 5a158b67..1a562594 100644 --- a/src/seedu/addressbook/AddressBook.java +++ b/src/seedu/addressbook/AddressBook.java @@ -618,10 +618,36 @@ private static String getUserInput() { /** * Shows a message to the user */ - private static void showToUser(String... message) { + /*private static void showToUser(String... message) { for (String m : 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); } /** From 37d763f57d227405af0991d0eae32d2f4e1156e3 Mon Sep 17 00:00:00 2001 From: "LAPTOP-80LTHV2A\\Hypertun" Date: Tue, 30 Jan 2018 22:13:59 +0800 Subject: [PATCH 2/3] Homework2 --- src/seedu/addressbook/AddressBook.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/seedu/addressbook/AddressBook.java b/src/seedu/addressbook/AddressBook.java index 1a562594..48b1546d 100644 --- a/src/seedu/addressbook/AddressBook.java +++ b/src/seedu/addressbook/AddressBook.java @@ -618,13 +618,13 @@ private static String getUserInput() { /** * Shows a message to the user */ - /*private static void showToUser(String... message) { + private static void showToUser(String... message) { for (String m : message) { System.out.println(LINE_PREFIX + m); } - }*/ + } //Without Varargs - private static void showToUser(String message) { + /*private static void showToUser(String message) { System.out.println(LINE_PREFIX + message); } private static void showToUser(String message, String message2) { @@ -648,7 +648,7 @@ private static void showToUser(String message, String message2,String message3,S 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. From 85e7c4652688e2dfc88411b9e676c67414d3b835 Mon Sep 17 00:00:00 2001 From: "LAPTOP-80LTHV2A\\Hypertun" Date: Fri, 2 Feb 2018 15:23:25 +0800 Subject: [PATCH 3/3] MethodAbstraction --- src/seedu/addressbook/AddressBook.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/seedu/addressbook/AddressBook.java b/src/seedu/addressbook/AddressBook.java index 48b1546d..bd7442d1 100644 --- a/src/seedu/addressbook/AddressBook.java +++ b/src/seedu/addressbook/AddressBook.java @@ -1015,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); } @@ -1038,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); } @@ -1172,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, ""); } /**