From c1803bc34b2d81feb1bfe27b985d6d53566eaa9f Mon Sep 17 00:00:00 2001
From: tmnaqeesha <tmnaqeesha@users.noreply.github.com>
Date: Tue, 6 May 2025 01:28:14 +0200
Subject: [PATCH] fix: Modify code for addItemBook

---
 .../opinion/Member.class                      | Bin 1315 -> 1313 bytes
 .../opinion/SocialNetwork.class               | Bin 5026 -> 5762 bytes
 src/opinion/Book.java                         |  59 +++---
 src/opinion/SocialNetwork.java                | 175 ++++++++++++------
 src/tests/AddItemBookTest.java                |   6 +-
 5 files changed, 144 insertions(+), 96 deletions(-)

diff --git a/out/production/infrastructureLogicielleClient/opinion/Member.class b/out/production/infrastructureLogicielleClient/opinion/Member.class
index 824d8034b28d2b0bec55038626bb054a9d641a83..634aa10b77e3bd83e05c4609611987517fba92d4 100644
GIT binary patch
delta 80
zcmZ3?wUBEAKa;44Pkwr4o`RJEBUeCCep+Tus+9ucW;LeijDnI3EDTZ%oD9+od<-%S
k!VI#L&oM_as!Y~ov0>DioW^3qXgYZ@iz}n;<d-Z~0OoWO7ytkO

delta 90
zcmZ3;wU}!IKa;qaPkwr4o`RJEqe4JYep+Tus+9sGm%?Thrs<4=q6{nyVho%N;tYHY
r5)8r&l9SIcM=@$nUdSRk*@i`((Fn|{WKn0dp1hF7mC=3ja~3NAsTLIR

diff --git a/out/production/infrastructureLogicielleClient/opinion/SocialNetwork.class b/out/production/infrastructureLogicielleClient/opinion/SocialNetwork.class
index 31b85354a7afa51719a2d6b71378b0a18e67e509..3b11728184a05dad4c2b5ade53362ab5c3de7a85 100644
GIT binary patch
literal 5762
zcmX^0Z`VEs1_l>~8(a)b49x5dEIbUX3~Y=H0$GV=iTXK-dFlH8Nm;4MC5#MgHko;u
zC3cJq%o>_u><k=?3?g7fr6rj;`aYR?*{LZ$nZ+es4D1ZdoDAFyJnRg-JPdpc{EQ5u
z`30GInfZD8!THIVi8+3$CFS`=*^CTaIhn;JzNxuMsYQ$oVm{c6vj!O@$ipB6GKT}C
z-YGvn8zd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21ZaN1}*z0K+8To
zp>iKkDn%~-q!GoRw(d5D%3TaK3=BTY|3A{+z`(!&iC{><Hmjb2nPE1A9K#$2O@_G)
zIt=r`?go`?atz$?l1&fl17-$ohBe^q2r1c^{xWd0Gib6iNd96_U|?ieOGL=50NVfy
z8GlGU1PTRMnFb3QkQnhHvyNds12aSG<nyAE;4&4GD%OE56JuZkCmWbu9N-kd2##1t
z;RvadH!yHAY-HF34Pk9?{m8(8k<_+>4TV&sj0~F@wtxe5D>wygW7y6h4N9Vn47(T@
W8FnxnU;wp17#R*S9A-GmAPE3YWXePU

diff --git a/src/opinion/Book.java b/src/opinion/Book.java
index e9e4890..cb0efbc 100644
--- a/src/opinion/Book.java
+++ b/src/opinion/Book.java
@@ -1,7 +1,5 @@
 package opinion;
 
-import java.util.LinkedList;
-
 /**
  * This class allows us to create books and to register new books
  */
@@ -12,14 +10,12 @@ public class Book {
     private int nbPages;
     private float mark;
 
-
-
     /**
-     * Initialization of private class variables by the constructor
-     * @param title
-     * @param kind
-     * @param author
-     * @param nbPages
+     * Initialization of private variables with constructor
+     * @param title The title of the book
+     * @param kind The type of the book
+     * @param author The author of the book
+     * @param nbPages The number of pages of the book
      */
     public Book(String title, String kind, String author, int nbPages) {
         this.title = title;
@@ -28,62 +24,51 @@ public class Book {
         this.nbPages = nbPages;
     }
 
-
     /**
-     * String function to retrieve the book's title
-     * @return
+     * Return the title of the book
+     * @return book's title
      */
     public String getTitle() {
         return this.title;
     }
 
-
     /**
-     * String function to retrieve the book's kind
-     * @return the kind of the book
+     * Return the kind of the book
+     * @return book's kind
      */
     public String getKind() {
         return this.kind;
     }
 
-
     /**
-     * String function to retrieve the book's author
-     * @return the author
+     * Retrieve the author of the book
+     * @return book's author
      */
     public String getAuthor() {
         return this.author;
     }
 
-
     /**
-     * Integer function to retrieve the book's number of pages
-     * @return the number of pages
+     * Return the number of pages of the book
+     * @return book's page number
      */
     public int getNbPages() {
         return this.nbPages;
     }
 
-
-
     /**
-     * Boolean function to know if the book is already present in the database
-     * @param title
-     * @return true or false
+     * Identify if the current book's title is similar as another book
+     * @param title2 other's book's title
+     * @return true if same, false if different
      */
-    public boolean isCalled(String title) {
-        String titleUpperCase = this.title.toUpperCase().trim();
-        if(titleUpperCase.equals(title.toUpperCase().trim())) {
-            return true;
-        }
-        return false;
+    public boolean compareTitle(String title2) {
+        String formattedTitle = this.title.toUpperCase().trim();
+        String formattedTitle2 = title2.toUpperCase().trim();
+        return formattedTitle.equals(formattedTitle2);
     }
-
-
-
     /**
-     * String function to didsplay the values of a book
-     * @return the values
+     * String function to display the details of a book
+     * @return the book's details
      */
     public String toString() {
         return "Book : "+getTitle()+"\nKind : "+getKind()+"\nAuthor : "+getAuthor()+"\nNumber of pages : "+getNbPages();
diff --git a/src/opinion/SocialNetwork.java b/src/opinion/SocialNetwork.java
index bd05cc5..c54cf3c 100644
--- a/src/opinion/SocialNetwork.java
+++ b/src/opinion/SocialNetwork.java
@@ -32,9 +32,9 @@ public class SocialNetwork implements ISocialNetwork {
 	 */
 	public SocialNetwork() {
 		listMember = new LinkedList<Member>();
-		nbmembers=0;
-		nbbooks=0;
-
+		listBook = new LinkedList<Book>();
+		nbmembers = 0;
+		nbbooks = 0;
 	}
 
 	/**
@@ -49,6 +49,7 @@ public class SocialNetwork implements ISocialNetwork {
 
 	/**
 	 * Returns number of films.
+	 * @return 0
 	 */
 	@Override
 	public int nbFilms() {
@@ -58,54 +59,85 @@ public class SocialNetwork implements ISocialNetwork {
 
 	/**
 	 * Returns number of books.
+	 * @return number of books
 	 */
 	@Override
 	public int nbBooks() {
 		// TODO Auto-generated method stub
-		return 0;
+		return nbbooks;
 	}
 
 	/**
 	 * Checks whether a member already exists.
-	 * @param login the login to check
+	 * @param login the login to be checked
 	 * @return true if login exists, else return false
 	 */
 	public boolean memberRegister(String login) {
-		for(Member m : listMember) {
-			if(m.getLogin().toUpperCase().trim().equals(login.toUpperCase().trim())) {
-
-				if (m.getPassword().toUpperCase().trim().equals(login.toUpperCase().trim())) {
-					return true;
-				}
+		for (Member m : listMember) {
+			if (m.getLogin().trim().equalsIgnoreCase(login.trim())) {
+				return true;
 			}
-		}return false;
+		}
+		return false;
 	}
 
+	/**
+	 * Validates the format of a user's login and password (not empty or too short)
+	 * @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
+	 */
 	public boolean validateuser(String login, String password) throws BadEntryException{
 		boolean result = false;
-		if(login==null || login.length()<=1 ){
+		if(login == null || login.length() <= 1){
 			throw new BadEntryException("login is null or empty");
 		}
-		if(password==null || password.length()<=1 ){
+		if(password == null || password.length() <= 1 ){
 			throw new BadEntryException("password is null or empty");
 		}
+		return true;
+	}
 
-
-		else
-			return true;
+	/**
+	 * Authenticates a user's login and password
+	 * @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
+	 */
+	private boolean authenticateUser(String login, String password) {
+		for (Member m : listMember) {
+			if (m.getLogin().trim().equalsIgnoreCase(login.trim()) &&
+					m.getPassword().trim().equals(password.trim())) {
+				return true;
+			}
+		}
+		return false;
 	}
 
+	/**
+	 * Checks if a book title is valid (not empty or too short) and if the book already exists
+	 * @param title the title of the book to be validated
+	 * @return true if book does not exist yet in system, false if already exists
+	 * @throws BadEntryException if title is empty or too short
+	 */
 	public boolean validatebook(String title) throws BadEntryException {
 		boolean result = false;
-		if(title==null || title.length()<=1 ){
+		if(title == null || title.length() <= 1 ){
 			throw new BadEntryException("title is null or empty");
 		}
-		for(Book b : listBook) {
-			if(title.toUpperCase().trim().equals(book.getTitle().toUpperCase().trim())) {
-				result = true;
+//		for(Book b : listBook) {
+//			if(title.toUpperCase().trim().equals(book.getTitle().toUpperCase().trim())) {
+//				result = true;
+//			}
+//		}
+//		return result;
+		for (Book b : listBook) {
+			if (b.compareTitle(title)) {
+				return true;
 			}
 		}
-		return result;
+		return false;
 	}
 
 	/**
@@ -118,48 +150,71 @@ public class SocialNetwork implements ISocialNetwork {
 	 */
 	@Override
 	public void addMember(String login, String password, String profile) throws BadEntryException, MemberAlreadyExistsException{
-		if (profile==null){
+		if (profile == null){
 			throw new BadEntryException("profile is null or empty");
 		}
+		validateuser(login, password);
 		if (memberRegister(login)) {
 			throw new MemberAlreadyExistsException();
 		}
-		if(validateuser(login, password) ){
-			member = new Member(login, password, profile);
-			listMember.add(member);
-			nbmembers++;
-		}
-
-		if(validateuser(login, password) ){
-			member = new Member(login, password, profile);
-			listMember.add(member);
-			nbmembers++;
-		}
-
-
-
-
+		member = new Member(login.trim(), password.trim(), profile.trim());
+		listMember.add(member);
+		nbmembers++;
 	}
 
+	/**
+	 * Adds a new book to the social network.
+	 * @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
+	 * @throws ItemBookAlreadyExistsException if book already exists in system
+	 */
 	@Override
-	public void addItemBook(String login, String password, String title,
-							String kind, String author, int nbPages) throws BadEntryException,
-			NotMemberException, ItemBookAlreadyExistsException {
-		if (validateuser(login,password)){
-			if (!memberRegister(login)) {
-				throw new NotMemberException("This user does not exist");
-
-			}
-			if (validatebook(title)) {
+	public void addItemBook(String login, String password, String title, String kind, String author, int nbPages) throws BadEntryException, NotMemberException, ItemBookAlreadyExistsException {
+		validateuser(login, password);
+		if (title == null || title.trim().isEmpty())
+			throw new BadEntryException("Error: Invalid title.");
+		if (kind == null || kind.trim().isEmpty())
+			throw new BadEntryException("Error: Invalid kind.");
+		if (author == null || author.trim().isEmpty())
+			throw new BadEntryException("Error: Invalid author.");
+		if (nbPages <= 0)
+			throw new BadEntryException("Error: Invalid number of pages.");
+		if (!authenticateUser(login, password))
+			throw new NotMemberException("Error: User doesn't exist");
+		for (Book b : listBook) {
+			if (b.compareTitle(title)) {
 				throw new ItemBookAlreadyExistsException();
 			}
-			else{
-				book = new Book(title, kind, author, nbPages);
-				listBook.add(book);
-			}
 		}
+		Book newBook = new Book(title.trim(), kind.trim(), author.trim(), nbPages);
+		listBook.add(newBook);
+		nbbooks++;
 	}
 
+//	public void addItemBook(String login, String password, String title,
+//							String kind, String author, int nbPages) throws BadEntryException,
+//			NotMemberException, ItemBookAlreadyExistsException {
+//		if (validateuser(login,password)){
+//			if (!memberRegister(login)) {
+//				throw new NotMemberException("This user does not exist");
+//
+//			}
+//			if (validatebook(title)) {
+//				throw new ItemBookAlreadyExistsException();
+//			}
+//			else{
+//				book = new Book(title, kind, author, nbPages);
+//				listBook.add(book);
+//			}
+//		}
+//	}
+
 	@Override
 	public void addItemFilm(String login, String password, String title, String kind, String director, String scriptwriter, int duration)
 			throws BadEntryException, NotMemberException, ItemFilmAlreadyExistsException {
@@ -172,14 +227,22 @@ public class SocialNetwork implements ISocialNetwork {
 		return 0;
 	}
 
+	/**
+	 * Displays a whole list of registered members
+	 * @return list of registered members
+	 */
 	public String toString(){
-		String ret = "";
-		for (Member m : listMember) {
-			ret += m.toString() + "\n";
+		if (listMember.isEmpty()) {
+			return "There are currently no registered members :(";
 		}
-		return ret;
+		String ret = "\nRegistered members:\n";
+		int counter = 1;
+		for (Member m : listMember) {
+            ret += counter + ". " + m.toString() + "\n";
+			counter++;
+        }
+		return ret.trim();
 		//return (listMember.toString());
-
 	}
 
 	@Override
diff --git a/src/tests/AddItemBookTest.java b/src/tests/AddItemBookTest.java
index 282be8f..2b559e2 100644
--- a/src/tests/AddItemBookTest.java
+++ b/src/tests/AddItemBookTest.java
@@ -272,9 +272,9 @@ public class AddItemBookTest {
         // exception
 
         //populate 'sn' with 3 members
-        nbErrors += addMemberOKTest(sn,"Paul","paul","","1.0a");
-        nbErrors += addMemberOKTest(sn,"Antoine","antoine","", "1.0b");
-        nbErrors += addMemberOKTest(sn,"Alice", "alice","",  "1.0c");
+        nbErrors += addMemberOKTest(sn,"Paul","paul","Student","1.0a");
+        nbErrors += addMemberOKTest(sn,"Antoine","antoine","Philosopher", "1.0b");
+        nbErrors += addMemberOKTest(sn,"Alice", "alice","F1 driver",  "1.0c");
 
 
         nbTests++;
-- 
GitLab