Skip to content

Commit

Permalink
Merge pull request nus-cs2113-AY2324S2#85 from liuzehui03/expanding_f…
Browse files Browse the repository at this point in the history
…ind_function

Expanding find function and update user guide
  • Loading branch information
liuzehui03 authored Apr 4, 2024
2 parents 1a30ca0 + df89a37 commit dd5093a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 18 deletions.
10 changes: 5 additions & 5 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ experience.
## Features

### Viewing all commands: `help`
View all the commands available in BookBuddy and instructions on their usage.
View all the commands available in BookBuddy and specific instructions on how the commands should be used.

Format: `help`

Expand Down Expand Up @@ -109,7 +109,7 @@ alright.. i've removed Harry Potter from the list.
````

### Viewing all books: `list`
Shows all books in the list along with their titles and status.
Shows all books stored in the list along with their titles and read or unread status.

Format: `list`

Expand Down Expand Up @@ -162,7 +162,7 @@ Successfully marked Harry Potter as unread.

### Setting the genre of a book: `set-genre`

Sets the genre of a specific book to the provided input.
Sets the genre of a specific book based on the provided input.

Format: `set-genre [BOOK_INDEX]` followed by `[NUMBER]` then `[CUSTOM_GENRE]` if 6 is entered
in the previous step
Expand Down Expand Up @@ -316,9 +316,9 @@ Example output:
````

### Finding a book by genre: `find-genre`
Returns all books in the book list that has the matching genre.
Returns all books in the saved book list that are stored under the matching genre.

Format: `find-genre` followed by `[NUMBER]`
Format: `find-genre` then user will be prompted to enter a `[NUMBER]` , the index corresponding to the available genre.

Example of usage with expected output:

Expand Down
23 changes: 10 additions & 13 deletions src/main/java/seedu/bookbuddy/Ui.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@ public static void printWelcome() {
System.out.println("How can I help you today?");
printShortLine();
}

public static void printLine() {
System.out.println("___________________________________");
}
public static void printShortLine() {
System.out.println("_____________");
}

public static void printExitMessage() {
System.out.println("Thank you for using BookBuddy! Hope to see you again keke :)");
}
Expand All @@ -37,31 +35,25 @@ public static void addBookMessage(String title) {
System.out.println("okii added [" + title + "] to the list.");
System.out.println("remember to read it soon....");
}

public static void labelBookMessage(String title, String label) {
System.out.println("okii labeled [" + title + "] as [" + label + "]");
System.out.println("remember to read it soon....");
}

public static void summaryBookMessage(String title, String summary) {
System.out.println("okii you have written: [" + summary + "] for the book: [" + title + "]");
System.out.println("remember to read it soon....");
}

public static void setGenreBookMessage(String title, String genre) {
System.out.println("okii categorised [" + title + "] as [" + genre + "]");
System.out.println("remember to read it soon....");
}

public static void setRatingBookMessage(String title, int rating) {
System.out.println("okii set rating for [" + title + "] as [" + rating +"]");
System.out.println("remember to read it soon....");
}

public static void removeBookMessage(int index, BookList books) {
System.out.println("alright.. i've removed " + Title.getTitle(books.getBook(index)) + " from the list.");
}

public static void helpMessage() {
System.out.println("Here's a list of commands to get you started!!");
System.out.println("add [BOOK_TITLE] -> to add new books to the list");
Expand All @@ -76,7 +68,6 @@ public static void helpMessage() {
System.out.println("list-rated -> to sort books by rating in descending order");
System.out.println("display [BOOK_INDEX] -> to view more details about a book");
System.out.println("find-title [KEYWORD] -> to find books with keyword in their title");
System.out.println("find-genre -> to see all books with the selected genre");
System.out.println("bye -> to exit BookBuddy software");
}

Expand All @@ -85,19 +76,25 @@ public static void printBookFound(ArrayList<BookMain> bookTitles){
System.out.println(i + 1 + ". " + bookTitles.get(i));
}
}

public static void printNoBookFound(){
System.out.println("no such books added...");

}

public static void printGenresFound(ArrayList<BookMain> bookGenres){
for (int i = 0; i < bookGenres.size(); i++) {
System.out.println(i + 1 + ". " + bookGenres.get(i));
}
}

public static void printNoGenresFound(){
System.out.println("no such books added...");
}
public static void printReadFound(ArrayList<BookMain> bookRead){
for (int i = 0; i < bookRead.size(); i++) {
System.out.println(i + 1 + ". " + bookRead.get(i));
}
}
public static void printUnreadFound(ArrayList<BookMain> bookUnread){
for (int i = 0; i < bookUnread.size(); i++) {
System.out.println(i + 1 + ". " + bookUnread.get(i));
}
}
}
17 changes: 17 additions & 0 deletions src/main/java/seedu/bookbuddy/bookdetailsmodifier/BookDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,21 @@ public static void findBookGenre(BookList bookList, String genre) {
Ui.printGenresFound(bookGenres);
}
}
public static void findMarkStatus(BookList bookList, String status){
ArrayList<BookMain> bookRead = new ArrayList<>();
ArrayList<BookMain> bookUnread = new ArrayList<>();
for (BookMain book : bookList.getBooks()) {
if (Read.getRead(book)) {
bookRead.add(book);
} else {
bookUnread.add(book);
}
}
if (bookRead.isEmpty() || bookUnread.isEmpty()){
Ui.printNoGenresFound();
} else {

Ui.printGenresFound(bookRead);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,7 @@ public static void parseFindGenre(BookList books) {
}
BookDisplay.findBookGenre(books, selectedGenre);
}
public static void parseFindStatus(BookList books, String inputArray) {
BookDisplay.findMarkStatus(books, inputArray);
}
}

0 comments on commit dd5093a

Please sign in to comment.