Skip to content

Commit

Permalink
Merge pull request nus-cs2113-AY2324S2#94 from liuzehui03/master
Browse files Browse the repository at this point in the history
fix bug such that capitalization of letters do not matter when using …
  • Loading branch information
liuzehui03 authored Apr 4, 2024
2 parents f30228c + 27e46ca commit c0194a2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 22 deletions.
8 changes: 8 additions & 0 deletions BookBuddy.log.1
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,11 @@ Apr 03, 2024 12:57:30 PM seedu.bookbuddy.parser.ParserMain parseCommand
WARNING: Sorry but that is not a valid command. Please try again
Apr 03, 2024 12:57:30 PM seedu.bookbuddy.parser.parservalidation.Exceptions handleException
WARNING: Command is invalid: Sorry but that is not a valid command. Please try again or type: help
Apr 04, 2024 11:43:24 PM seedu.bookbuddy.parser.parservalidation.Exceptions validateCommandArguments
WARNING: The add Command requires a book title
Apr 04, 2024 11:43:24 PM seedu.bookbuddy.parser.parservalidation.Exceptions handleException
WARNING: Invalid command argument: The add Command requires a book title
Apr 04, 2024 11:43:24 PM seedu.bookbuddy.parser.ParserMain parseCommand
WARNING: Sorry but that is not a valid command. Please try again
Apr 04, 2024 11:43:24 PM seedu.bookbuddy.parser.parservalidation.Exceptions handleException
WARNING: Command is invalid: Sorry but that is not a valid command. Please try again or type: help
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static void printAllBooks(BookList bookList) {
public static void findBookTitle(BookList bookList, String title) {
ArrayList<BookMain> bookTitles = new ArrayList<>();
for (BookMain book : bookList.getBooks()) {
if (Title.getTitle(book).contains(title)) {
if (Title.getTitle(book).toLowerCase().contains(title.toLowerCase())) {
bookTitles.add(book);
}
}
Expand All @@ -77,7 +77,8 @@ public static void findBookTitle(BookList bookList, String title) {
public static void findBookGenre(BookList bookList, String genre) {
ArrayList<BookMain> bookGenres = new ArrayList<>();
for (BookMain book : bookList.getBooks()) {
if (Genre.getGenre(book).contains(genre)) {
String actualGenre = Genre.getGenre(book).toLowerCase();
if (actualGenre.contains(genre.toLowerCase())) {
bookGenres.add(book);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/bookbuddy/parser/ParserMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static void parseCommand(String input, BookList books) {
ParserFind.parseTitle(books, inputArray[1]);
break;
case CommandList.FIND_GENRE_COMMAND:
ParserFind.parseFindGenre(books);
ParserFind.parseFindGenre(books, inputArray[1]);
break;
case CommandList.FIND_READ_COMMAND:
ParserFind.parseFindRead(books);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,14 @@
import seedu.bookbuddy.bookdetailsmodifier.BookDisplay;
import seedu.bookbuddy.booklist.BookList;

import java.util.Scanner;

import static seedu.bookbuddy.parser.parsercommands.ParserGenre.invalidInputLooper;

public class ParserFind {
public static void parseTitle(BookList books, String inputArray) {
BookDisplay.findBookTitle(books, inputArray);
}

public static void parseFindGenre(BookList books) {
//BookDisplay.findBookGenre(books, inputArray);
System.out.println("Available genres:");
for (int i = 0; i < BookList.getAvailableGenres().size(); i++) {
System.out.println((i + 1) + ". " + BookList.getAvailableGenres().get(i));
}
System.out.println("Enter the number for the desired genre:");
Scanner scanner = new Scanner(System.in);
String genre = String.valueOf(scanner);
String selectedGenre = null;
selectedGenre = invalidInputLooper(selectedGenre, scanner);
if (selectedGenre == null) {
return;
}
BookDisplay.findBookGenre(books, selectedGenre);
public static void parseFindGenre(BookList books, String inputArray) {
BookDisplay.findBookGenre(books, inputArray);

}
public static void parseFindRead(BookList books) {
BookDisplay.findRead(books);
Expand Down

0 comments on commit c0194a2

Please sign in to comment.