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

Remove unnecessary whitespaces from outputs #233 #513

Closed
Closed
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
2 changes: 1 addition & 1 deletion src/seedu/addressbook/common/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class Messages {

public static final String MESSAGE_GOODBYE = "Good bye!";
public static final String MESSAGE_INIT_FAILED = "Failed to initialise address book application. Exiting...";
public static final String MESSAGE_INVALID_COMMAND_FORMAT = "Invalid command format! \n%1$s";
public static final String MESSAGE_INVALID_COMMAND_FORMAT = "Invalid command format!\n%1$s";
public static final String MESSAGE_INVALID_PERSON_DISPLAYED_INDEX = "The person index provided is invalid";
public static final String MESSAGE_PERSON_NOT_IN_ADDRESSBOOK = "Person could not be found in address book";
public static final String MESSAGE_PERSONS_LISTED_OVERVIEW = "%1$d persons listed!";
Expand Down
10 changes: 10 additions & 0 deletions src/seedu/addressbook/data/person/ReadOnlyPerson.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,13 @@ default String getAsTextShowAll() {
}
builder.append(getAddress())
.append(" Tags: ");
boolean hasTags = false;
for (Tag tag : getTags()) {
builder.append(tag);
hasTags = true;
}
if (hasTags == false) {
builder.append("[NONE]");
}
return builder.toString();
}
Expand All @@ -90,8 +95,13 @@ default String getAsTextHidePrivate() {
builder.append(" Address: ").append(getAddress());
}
builder.append(" Tags: ");
boolean hasTags = false;
for (Tag tag : getTags()) {
builder.append(tag);
hasTags = true;
}
if (hasTags == false) {
builder.append("[NONE]");
}
return builder.toString();
}
Expand Down
15 changes: 13 additions & 2 deletions src/seedu/addressbook/ui/TextUi.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public class TextUi {
/** A decorative prefix added to the beginning of lines printed by AddressBook */
private static final String LINE_PREFIX = "|| ";

/** Same as LINE_PREFIX but no space */
private static final String LINE_PREFIX_NO_SPACE = "||";

/** A platform independent line separator. */
private static final String LS = System.lineSeparator();

Expand Down Expand Up @@ -118,8 +121,16 @@ public void showInitFailedMessage() {

/** Shows message(s) to the user */
public void showToUser(String... message) {
for (String m : message) {
out.println(LINE_PREFIX + m.replace("\n", LS + LINE_PREFIX));
int noOfMessages = message.length;
for (int i = 0; i < noOfMessages; i++) {
String m = message[i];
String finalPrefix;
if (i == noOfMessages - DISPLAYED_INDEX_OFFSET) {
finalPrefix = LINE_PREFIX_NO_SPACE;
} else {
finalPrefix = LINE_PREFIX;
}
out.println(LINE_PREFIX + m.replace("\n", LS + finalPrefix));
}
}

Expand Down
96 changes: 48 additions & 48 deletions test/EXPECTED.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,25 @@
|| 0 persons listed!
|| ===================================================
|| Enter command: || [Command entered: add wrong args wrong args]
|| Invalid command format!
|| Invalid command format!
|| add: Adds a person to the address book. Contact details can be marked private by prepending 'p' to the prefix.
|| Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [t/TAG]...
|| Example: add John Doe p/98765432 e/[email protected] a/311, Clementi Ave 2, #02-25 t/friends t/owesMoney
|| ===================================================
|| Enter command: || [Command entered: add Valid Name 12345 e/[email protected] a/valid, address]
|| Invalid command format!
|| Invalid command format!
|| add: Adds a person to the address book. Contact details can be marked private by prepending 'p' to the prefix.
|| Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [t/TAG]...
|| Example: add John Doe p/98765432 e/[email protected] a/311, Clementi Ave 2, #02-25 t/friends t/owesMoney
|| ===================================================
|| Enter command: || [Command entered: add Valid Name p/12345 [email protected] a/valid, address]
|| Invalid command format!
|| Invalid command format!
|| add: Adds a person to the address book. Contact details can be marked private by prepending 'p' to the prefix.
|| Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [t/TAG]...
|| Example: add John Doe p/98765432 e/[email protected] a/311, Clementi Ave 2, #02-25 t/friends t/owesMoney
|| ===================================================
|| Enter command: || [Command entered: add Valid Name p/12345 e/[email protected] valid, address]
|| Invalid command format!
|| Invalid command format!
|| add: Adds a person to the address book. Contact details can be marked private by prepending 'p' to the prefix.
|| Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [t/TAG]...
|| Example: add John Doe p/98765432 e/[email protected] a/311, Clementi Ave 2, #02-25 t/friends t/owesMoney
Expand All @@ -86,66 +86,66 @@
|| Tags names should be alphanumeric
|| ===================================================
|| Enter command: || [Command entered: add Adam Brown p/111111 e/[email protected] a/111, alpha street]
|| New person added: Adam Brown Phone: 111111 Email: [email protected] Address: 111, alpha street Tags:
|| New person added: Adam Brown Phone: 111111 Email: [email protected] Address: 111, alpha street Tags: [NONE]
|| ===================================================
|| Enter command: || [Command entered: list]
|| 1. Adam Brown Phone: 111111 Email: [email protected] Address: 111, alpha street Tags:
||
|| 1. Adam Brown Phone: 111111 Email: [email protected] Address: 111, alpha street Tags: [NONE]
||
|| 1 persons listed!
|| ===================================================
|| Enter command: || [Command entered: add Betsy Choo pp/222222 pe/[email protected] pa/222, beta street t/secretive]
|| New person added: Betsy Choo Phone: (private) 222222 Email: (private) [email protected] Address: (private) 222, beta street Tags: [secretive]
|| ===================================================
|| Enter command: || [Command entered: list]
|| 1. Adam Brown Phone: 111111 Email: [email protected] Address: 111, alpha street Tags:
|| 2. Betsy Choo Tags: [secretive]
||
|| 1. Adam Brown Phone: 111111 Email: [email protected] Address: 111, alpha street Tags: [NONE]
|| 2. Betsy Choo Tags: [secretive]
||
|| 2 persons listed!
|| ===================================================
|| Enter command: || [Command entered: add Charlie Dickson pp/333333 e/[email protected] a/333, gamma street t/friends t/school]
|| New person added: Charlie Dickson Phone: (private) 333333 Email: [email protected] Address: 333, gamma street Tags: [school][friends]
|| ===================================================
|| Enter command: || [Command entered: list]
|| 1. Adam Brown Phone: 111111 Email: [email protected] Address: 111, alpha street Tags:
|| 2. Betsy Choo Tags: [secretive]
|| 3. Charlie Dickson Email: [email protected] Address: 333, gamma street Tags: [school][friends]
||
|| 1. Adam Brown Phone: 111111 Email: [email protected] Address: 111, alpha street Tags: [NONE]
|| 2. Betsy Choo Tags: [secretive]
|| 3. Charlie Dickson Email: [email protected] Address: 333, gamma street Tags: [school][friends]
||
|| 3 persons listed!
|| ===================================================
|| Enter command: || [Command entered: add Dickson Ee p/444444 pe/[email protected] a/444, delta street t/friends]
|| New person added: Dickson Ee Phone: 444444 Email: (private) [email protected] Address: 444, delta street Tags: [friends]
|| ===================================================
|| Enter command: || [Command entered: list]
|| 1. Adam Brown Phone: 111111 Email: [email protected] Address: 111, alpha street Tags:
|| 2. Betsy Choo Tags: [secretive]
|| 3. Charlie Dickson Email: [email protected] Address: 333, gamma street Tags: [school][friends]
|| 4. Dickson Ee Phone: 444444 Address: 444, delta street Tags: [friends]
||
|| 1. Adam Brown Phone: 111111 Email: [email protected] Address: 111, alpha street Tags: [NONE]
|| 2. Betsy Choo Tags: [secretive]
|| 3. Charlie Dickson Email: [email protected] Address: 333, gamma street Tags: [school][friends]
|| 4. Dickson Ee Phone: 444444 Address: 444, delta street Tags: [friends]
||
|| 4 persons listed!
|| ===================================================
|| Enter command: || [Command entered: add Esther Potato p/555555 e/[email protected] pa/555, epsilon street t/tubers t/starchy]
|| New person added: Esther Potato Phone: 555555 Email: [email protected] Address: (private) 555, epsilon street Tags: [tubers][starchy]
|| ===================================================
|| Enter command: || [Command entered: list]
|| 1. Adam Brown Phone: 111111 Email: [email protected] Address: 111, alpha street Tags:
|| 2. Betsy Choo Tags: [secretive]
|| 3. Charlie Dickson Email: [email protected] Address: 333, gamma street Tags: [school][friends]
|| 4. Dickson Ee Phone: 444444 Address: 444, delta street Tags: [friends]
|| 5. Esther Potato Phone: 555555 Email: [email protected] Tags: [tubers][starchy]
||
|| 1. Adam Brown Phone: 111111 Email: [email protected] Address: 111, alpha street Tags: [NONE]
|| 2. Betsy Choo Tags: [secretive]
|| 3. Charlie Dickson Email: [email protected] Address: 333, gamma street Tags: [school][friends]
|| 4. Dickson Ee Phone: 444444 Address: 444, delta street Tags: [friends]
|| 5. Esther Potato Phone: 555555 Email: [email protected] Tags: [tubers][starchy]
||
|| 5 persons listed!
|| ===================================================
|| Enter command: || [Command entered: add Esther Potato p/555555 e/[email protected] pa/555, epsilon street t/tubers t/starchy]
|| This person already exists in the address book
|| ===================================================
|| Enter command: || [Command entered: view]
|| Invalid command format!
|| Invalid command format!
|| view: Views the non-private details of the person identified by the index number in the last shown person listing.
|| Parameters: INDEX
|| Example: view 1
|| ===================================================
|| Enter command: || [Command entered: viewall]
|| Invalid command format!
|| Invalid command format!
|| viewall: Views the non-private details of the person identified by the index number in the last shown person listing.
|| Parameters: INDEX
|| Example: viewall 1
Expand Down Expand Up @@ -175,10 +175,10 @@
|| The person index provided is invalid
|| ===================================================
|| Enter command: || [Command entered: view 1]
|| Viewing person: Adam Brown Phone: 111111 Email: [email protected] Address: 111, alpha street Tags:
|| Viewing person: Adam Brown Phone: 111111 Email: [email protected] Address: 111, alpha street Tags: [NONE]
|| ===================================================
|| Enter command: || [Command entered: viewall 1]
|| Viewing person: Adam Brown Phone: 111111 Email: [email protected] Address: 111, alpha street Tags:
|| Viewing person: Adam Brown Phone: 111111 Email: [email protected] Address: 111, alpha street Tags: [NONE]
|| ===================================================
|| Enter command: || [Command entered: view 3]
|| Viewing person: Charlie Dickson Email: [email protected] Address: 333, gamma street Tags: [school][friends]
Expand All @@ -199,7 +199,7 @@
|| Viewing person: Esther Potato Phone: 555555 Email: [email protected] Address: (private) 555, epsilon street Tags: [tubers][starchy]
|| ===================================================
|| Enter command: || [Command entered: find]
|| Invalid command format!
|| Invalid command format!
|| find: Finds all persons whose names contain any of the specified keywords (case-sensitive) and displays them as a list with index numbers.
|| Parameters: KEYWORD [MORE_KEYWORDS]...
|| Example: find alice bob charlie
Expand All @@ -218,23 +218,23 @@
|| ===================================================
|| Enter command: || [Command entered: find Betsy]
|| 1. Betsy Choo Tags: [secretive]
||
||
|| 1 persons listed!
|| ===================================================
|| Enter command: || [Command entered: find Dickson]
|| 1. Charlie Dickson Email: [email protected] Address: 333, gamma street Tags: [school][friends]
|| 2. Dickson Ee Phone: 444444 Address: 444, delta street Tags: [friends]
||
|| 2. Dickson Ee Phone: 444444 Address: 444, delta street Tags: [friends]
||
|| 2 persons listed!
|| ===================================================
|| Enter command: || [Command entered: find Charlie Betsy]
|| 1. Betsy Choo Tags: [secretive]
|| 2. Charlie Dickson Email: [email protected] Address: 333, gamma street Tags: [school][friends]
||
|| 2. Charlie Dickson Email: [email protected] Address: 333, gamma street Tags: [school][friends]
||
|| 2 persons listed!
|| ===================================================
|| Enter command: || [Command entered: delete]
|| Invalid command format!
|| Invalid command format!
|| delete: Deletes the person identified by the index number used in the last person listing.
|| Parameters: INDEX
|| Example: delete 1
Expand Down Expand Up @@ -264,30 +264,30 @@
|| Person could not be found in address book
|| ===================================================
|| Enter command: || [Command entered: list]
|| 1. Adam Brown Phone: 111111 Email: [email protected] Address: 111, alpha street Tags:
|| 2. Betsy Choo Tags: [secretive]
|| 3. Dickson Ee Phone: 444444 Address: 444, delta street Tags: [friends]
|| 4. Esther Potato Phone: 555555 Email: [email protected] Tags: [tubers][starchy]
||
|| 1. Adam Brown Phone: 111111 Email: [email protected] Address: 111, alpha street Tags: [NONE]
|| 2. Betsy Choo Tags: [secretive]
|| 3. Dickson Ee Phone: 444444 Address: 444, delta street Tags: [friends]
|| 4. Esther Potato Phone: 555555 Email: [email protected] Tags: [tubers][starchy]
||
|| 4 persons listed!
|| ===================================================
|| Enter command: || [Command entered: delete 4]
|| Deleted Person: Esther Potato Phone: 555555 Email: [email protected] Address: (private) 555, epsilon street Tags: [tubers][starchy]
|| ===================================================
|| Enter command: || [Command entered: list]
|| 1. Adam Brown Phone: 111111 Email: [email protected] Address: 111, alpha street Tags:
|| 2. Betsy Choo Tags: [secretive]
|| 3. Dickson Ee Phone: 444444 Address: 444, delta street Tags: [friends]
||
|| 1. Adam Brown Phone: 111111 Email: [email protected] Address: 111, alpha street Tags: [NONE]
|| 2. Betsy Choo Tags: [secretive]
|| 3. Dickson Ee Phone: 444444 Address: 444, delta street Tags: [friends]
||
|| 3 persons listed!
|| ===================================================
|| Enter command: || [Command entered: delete 1]
|| Deleted Person: Adam Brown Phone: 111111 Email: [email protected] Address: 111, alpha street Tags:
|| Deleted Person: Adam Brown Phone: 111111 Email: [email protected] Address: 111, alpha street Tags: [NONE]
|| ===================================================
|| Enter command: || [Command entered: list]
|| 1. Betsy Choo Tags: [secretive]
|| 2. Dickson Ee Phone: 444444 Address: 444, delta street Tags: [friends]
||
|| 2. Dickson Ee Phone: 444444 Address: 444, delta street Tags: [friends]
||
|| 2 persons listed!
|| ===================================================
|| Enter command: || [Command entered: clear]
Expand Down