diff --git a/src/code/ca/bcit/comp2522/lab05/BookStore.java b/src/code/ca/bcit/comp2522/lab05/BookStore.java index bbb6cd1..f759333 100644 --- a/src/code/ca/bcit/comp2522/lab05/BookStore.java +++ b/src/code/ca/bcit/comp2522/lab05/BookStore.java @@ -23,19 +23,6 @@ public class BookStore { private final String bookStoreName; private final List novels; - /** - * validateString ensures string input is not null or empty - * @param str to validate - * @throws IllegalArgumentException if invalid string - */ - private static void validateString(final String str) - throws IllegalArgumentException - { - if (str == null || str.isEmpty()) { - throw new IllegalArgumentException("String cannot be null or empty"); - } - } - /** * BookStore constructor creats a bookstore, and tests * hash maps and iterators @@ -44,7 +31,7 @@ public class BookStore { public BookStore( final String bookStoreName ) { - validateString(bookStoreName); + Validator.validateString(bookStoreName); this.bookStoreName = bookStoreName; this.novels = new ArrayList<>(); diff --git a/src/code/ca/bcit/comp2522/lab05/Novel.java b/src/code/ca/bcit/comp2522/lab05/Novel.java index 01c7e9f..a2b4c7b 100644 --- a/src/code/ca/bcit/comp2522/lab05/Novel.java +++ b/src/code/ca/bcit/comp2522/lab05/Novel.java @@ -13,19 +13,6 @@ public class Novel implements Comparable { private final String authorName; private final int yearPublished; - /** - * validateString ensures given string is not null or empty - * @param str to validate - * @throws IllegalArgumentException if invlalid string - */ - private static void validateString(final String str) - throws IllegalArgumentException - { - if (str == null || str.isEmpty()) { - throw new IllegalArgumentException("String cannot be null or empty"); - } - } - /** * Novel constructor * @param title of novel @@ -37,8 +24,8 @@ public class Novel implements Comparable { final String authorName, final int yearPublished ) { - validateString(title); - validateString(authorName); + Validator.validateString(title); + Validator.validateString(authorName); this.title = title; this.authorName = authorName; @@ -59,7 +46,7 @@ public class Novel implements Comparable { /** * getYearPublished of the novel - * @return novel yearh published + * @return novel year published */ public int getYearPublished() { return this.yearPublished; } diff --git a/src/code/ca/bcit/comp2522/lab05/Validator.java b/src/code/ca/bcit/comp2522/lab05/Validator.java new file mode 100644 index 0000000..8cc64c1 --- /dev/null +++ b/src/code/ca/bcit/comp2522/lab05/Validator.java @@ -0,0 +1,24 @@ +package ca.bcit.comp2522.lab05; + +/** + * Validator is a helper class to validate inputs + * + * @author Braeden Sowinski + * @author Trishaan Shetty + * @author Nico Agostini + * @version 1.0.0 + */ +public class Validator { + /** + * validateString ensures string input is not null or empty + * @param str to validate + * @throws IllegalArgumentException if invalid string + */ + public static void validateString(final String str) + throws IllegalArgumentException + { + if (str == null || str.isEmpty()) { + throw new IllegalArgumentException("String cannot be null or empty"); + } + } +}