diff --git a/out/production/infrastructureLogicielleClient/crossTests/CrossAddItemFilmTest.class b/out/production/infrastructureLogicielleClient/crossTests/CrossAddItemFilmTest.class new file mode 100644 index 0000000000000000000000000000000000000000..d52d9fcafb70e7815b4480cd2403195dd945178d Binary files /dev/null and b/out/production/infrastructureLogicielleClient/crossTests/CrossAddItemFilmTest.class differ diff --git a/out/production/infrastructureLogicielleClient/tests/RenderingTest.class b/out/production/infrastructureLogicielleClient/tests/RenderingTest.class new file mode 100644 index 0000000000000000000000000000000000000000..2953abdab081e9883640ef1350a136612980d6db Binary files /dev/null and b/out/production/infrastructureLogicielleClient/tests/RenderingTest.class differ diff --git a/src/opinion/Film.java b/src/opinion/Film.java index 6dd31b12ce3be43b8df82378af03cacf31bbab6c..4326e7215514633ef7d6b85a305433a81ea59ae2 100644 --- a/src/opinion/Film.java +++ b/src/opinion/Film.java @@ -26,7 +26,8 @@ public class Film extends Item { @Override public String toString() { - return "Film Title: " + title + "\nKind: " + kind + "\nDirector: " + director + - "\nScenarist: " + scenarist + "\nDuration: " + duration + " minutes"; + return "Film Title: " + getTitle() + "\nKind: " + getKind() + "\nDirector: " + getDirector() + + "\nScenarist: " + getScenarist() + "\nDuration: " + getDuration() + " minutes"; } + } diff --git a/src/opinion/Item.java b/src/opinion/Item.java index ceaeba516f2027dffdf9ce3c9f84e37066ed8273..3677f4a72cdde4acb41343029a177ec5f1000f90 100644 --- a/src/opinion/Item.java +++ b/src/opinion/Item.java @@ -34,10 +34,13 @@ public abstract class Item { public boolean compareTitle(String title2) { if (this.title == null || title2 == null) return false; - String formattedTitle = this.title.trim().toUpperCase(); - String formattedTitle2 = title2.trim().toUpperCase(); - return formattedTitle.equals(formattedTitle2); + return normalize(this.title).equals(normalize(title2)); } + + private String normalize(String s) { + return s.trim().replaceAll("\\s+", "").toLowerCase(); + } + public void addOrUpdateReview(String login, float mark, String comment) { for (Review r : reviews) { if (r.getReviewerLogin().equalsIgnoreCase(login)) { diff --git a/src/opinion/SocialNetwork.java b/src/opinion/SocialNetwork.java index d19eb4397f17bad27c7ec232486a0f43763726e4..ac80da7880335ff9710d2fbfc27cfd9aaffcc33d 100644 --- a/src/opinion/SocialNetwork.java +++ b/src/opinion/SocialNetwork.java @@ -34,6 +34,14 @@ public class SocialNetwork implements ISocialNetwork { nbfilms = 0; } + /** + * @param args + */ + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + /** * Returns number of registered members. * @@ -44,9 +52,6 @@ public class SocialNetwork implements ISocialNetwork { return nbmembers; } - - - /** * Returns number of books. * @@ -75,7 +80,7 @@ public class SocialNetwork implements ISocialNetwork { /** * Validates the format of a user's login and password (not empty or too short) * - * @param login the login to be validated + * @param login the login to be validated * @param password the password to be validated * @return true if login and password are valid * @throws BadEntryException if either login or password is invalid @@ -94,7 +99,7 @@ public class SocialNetwork implements ISocialNetwork { /** * Authenticates a user's login and password * - * @param login the login of the user + * @param login the login of the user * @param password the password of the user * @return true if password corresponds to registered login, false if wrong password */ @@ -130,10 +135,10 @@ public class SocialNetwork implements ISocialNetwork { /** * Adds a new member to the social network. * - * @param login the new member's login + * @param login the new member's login * @param password the new member's password - * @param profile a free String describing the new member's profile - * @throws BadEntryException if parameter is null or too short + * @param profile a free String describing the new member's profile + * @throws BadEntryException if parameter is null or too short * @throws MemberAlreadyExistsException if login already exists */ @Override @@ -150,13 +155,16 @@ public class SocialNetwork implements ISocialNetwork { nbmembers++; } - @Override public void addItemFilm(String login, String password, String title, String kind, String director, String scriptwriter, int duration) throws BadEntryException, NotMemberException, ItemFilmAlreadyExistsException { validateUser(login, password); + if (login == null || login.trim().isEmpty()) + throw new BadEntryException("Error: Login is null or empty"); + if (password == null || password.trim().length() < 4) + throw new BadEntryException("Error: Password is null or too short"); if (title == null || title.trim().isEmpty()) throw new BadEntryException("Error: Title is null or empty"); if (kind == null || kind.trim().isEmpty()) @@ -180,6 +188,7 @@ public class SocialNetwork implements ISocialNetwork { listFilm.add(film); nbfilms++; } + /** * Returns number of films. * @@ -211,18 +220,18 @@ public class SocialNetwork implements ISocialNetwork { throw new NotItemException("Error: Film not found"); } - + /** * Adds a new book to the social network. * - * @param login login of the member adding the book + * @param login login of the member adding the book * @param password password of the member adding the book - * @param title the new book's title - * @param kind the new book's kind - * @param author the new book's author - * @param nbPages number of pages of the new book's - * @throws BadEntryException if any input is invalid (empty or number pages equal or less than 0) - * @throws NotMemberException if login or password is wrong + * @param title the new book's title + * @param kind the new book's kind + * @param author the new book's author + * @param nbPages number of pages of the new book's + * @throws BadEntryException if any input is invalid (empty or number pages equal or less than 0) + * @throws NotMemberException if login or password is wrong * @throws ItemBookAlreadyExistsException if book already exists in system */ @Override @@ -265,19 +274,16 @@ public class SocialNetwork implements ISocialNetwork { nbbooks++; } - - /** - * - * @param login login of the member adding the review + * @param login login of the member adding the review * @param password password of the member adding the review - * @param title the reviewed book's title - * @param mark the mark given by the member for this book - * @param comment the comment given by the member for this book + * @param title the reviewed book's title + * @param mark the mark given by the member for this book + * @param comment the comment given by the member for this book * @return average mark of current book - * @throws BadEntryException if any input is invalid (mark is out of range) + * @throws BadEntryException if any input is invalid (mark is out of range) * @throws NotMemberException if login or password is wrong - * @throws NotItemException if book doesn't exist + * @throws NotItemException if book doesn't exist */ @Override public float reviewItemBook(String login, String password, String title, float mark, String comment) @@ -311,7 +317,6 @@ public class SocialNetwork implements ISocialNetwork { } /** - * * @param title title of searched item(s) * @return the search result of book or film added * @throws BadEntryException if any input is invalid (title is empty or too short) @@ -359,12 +364,4 @@ public class SocialNetwork implements ISocialNetwork { } return ret.trim(); } - - /** - * @param args - */ - public static void main(String[] args) { - // TODO Auto-generated method stub - - } }