diff --git a/out/production/infrastructureLogicielleClient/opinion/Book.class b/out/production/infrastructureLogicielleClient/opinion/Book.class index f0972e96f383f2128c50e18372491c4e3843f9c3..dbdc2cd776a1d7fb9146f3653746c2aa23291368 100644 Binary files a/out/production/infrastructureLogicielleClient/opinion/Book.class and b/out/production/infrastructureLogicielleClient/opinion/Book.class differ diff --git a/out/production/infrastructureLogicielleClient/opinion/SocialNetwork.class b/out/production/infrastructureLogicielleClient/opinion/SocialNetwork.class index 37acf0e72b0dad6549446276e819536d633cdb5d..f72caf53502252cc68a317e97eb5f24e42b6d421 100644 Binary files a/out/production/infrastructureLogicielleClient/opinion/SocialNetwork.class and b/out/production/infrastructureLogicielleClient/opinion/SocialNetwork.class differ diff --git a/src/opinion/Book.java b/src/opinion/Book.java index 88f4112b5863ada526e87edf75bcc80c3be923a1..03c83d648ed510414f2147e39966f98dff2940aa 100644 --- a/src/opinion/Book.java +++ b/src/opinion/Book.java @@ -99,6 +99,12 @@ public class Book { * @return the book's details */ public String toString() { - return "Book : " + getTitle() + "\nKind : " + getKind() + "\nAuthor : " + getAuthor() + "\nNumber of pages : " + getNbPages(); + String text = "Book : " + getTitle() + "\nKind : " + getKind() + "\nAuthor : " + getAuthor() + "\nNumber of pages : " + getNbPages()+"\nOverall note: "+getAverageMark() +"\nReviews"; + int counter = 1; + for (Review r : reviews) { + text += counter + ". " + r.getReviewerLogin() + "\t" + r.getMark() + "\t" + r.getComment(); + counter++; + } + return text; } } diff --git a/src/opinion/SocialNetwork.java b/src/opinion/SocialNetwork.java index 239e01bb0727ec96e78111ec49db3b6a57c97c72..7a1c9b6bd1a51bc9dec9879276100450e68a945b 100644 --- a/src/opinion/SocialNetwork.java +++ b/src/opinion/SocialNetwork.java @@ -277,10 +277,23 @@ public class SocialNetwork implements ISocialNetwork { return targetBook.getAverageMark(); } + @Override - public LinkedList<String> consultItems(String title) - throws BadEntryException { - return new LinkedList<String>(); + public LinkedList<String> consultItems(String title) throws BadEntryException { + if (title == null || title.trim().length() <= 1) { + throw new BadEntryException("Title is null or too short."); + } + + String formattedTitle = title.trim().toLowerCase(); + LinkedList<String> result = new LinkedList<>(); + + for (Book b : listBook) { + if (b.getTitle().toLowerCase().contains(formattedTitle)) { + result.add(b.toString()); + } + } + + return result; } /** diff --git a/src/tests/ConsultItemBookTest.java b/src/tests/ConsultItemBookTest.java new file mode 100644 index 0000000000000000000000000000000000000000..a0b8e5def79756a605e556265deba75cc460282c --- /dev/null +++ b/src/tests/ConsultItemBookTest.java @@ -0,0 +1,19 @@ +package tests; + +public class ConsultItemBookTest { + + private static int nbTests = 0; + private static int nbErrors = 0; + private static void displaySuccess(String message) { + System.out.println("Test passed: " + message); + } + + private static void displayError(String message) { + System.out.println("Test failed: " + message); + nbErrors++; + } + public static void testConsultItemBook() { + nbTests++; + + } +}