forked from nus-cs2113-AY2324S2/tp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request nus-cs2113-AY2324S2#41 from yeozongyao/branch-zong…
…yao-categoriseBooks Categorise the books with personalised labels and with the genre
- Loading branch information
Showing
4 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package seedu.bookbuddy; | ||
|
||
import static seedu.bookbuddy.BookList.books; | ||
|
||
public class BookDetails { | ||
/** | ||
* Sets the label of the book at the specified index. | ||
* | ||
* @param index The index of the book in the list. | ||
* @param label The label to set for the book. | ||
* @throws IndexOutOfBoundsException if the index is out of range. | ||
*/ | ||
public static void setBookLabelByIndex(int index, String label) throws IndexOutOfBoundsException { | ||
// Check for valid index | ||
if (index < 0 || index >= books.size()) { | ||
throw new IndexOutOfBoundsException("Invalid book index. Please enter a valid index."); | ||
} | ||
|
||
// Set the label for the book at the specified index | ||
books.get(index).setLabel(label); | ||
String title = books.get(index).getTitle(); | ||
Ui.labelBookMessage(title, label); | ||
} | ||
|
||
/** | ||
* Sets the genre of the book at the specified index. | ||
* | ||
* @param index The index of the book in the list. | ||
* @param genre The genre to set for the book. | ||
* @throws IndexOutOfBoundsException if the index is out of range. | ||
*/ | ||
public static void setBookGenreByIndex(int index, String genre) throws IndexOutOfBoundsException { | ||
// Check for valid index | ||
if (index < 0 || index >= books.size()) { | ||
throw new IndexOutOfBoundsException("Invalid book index. Please enter a valid index."); | ||
} | ||
|
||
// Set the genre for the book at the specified index | ||
books.get(index).setGenre(genre); | ||
String title = books.get(index).getTitle(); | ||
Ui.setGenreBookMessage(title, genre); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters