Package opinion
Class SocialNetwork
java.lang.Object
opinion.SocialNetwork
- All Implemented Interfaces:
opinion.ISocialNetwork
Represents a social network.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a new book to the social network.void
addItemFilm
(String login, String password, String title, String kind, String director, String scriptwriter, int duration) Adds a new film to the social network.void
Adds a new member to the social network.consultItems
(String title) Consults items.<T> Item
Gets an item by its title and type.<T> LinkedList
<T> Gets the list of items in the social network.Gets a member by their login.Gets the list of members in the social network.static void
The main method of the SocialNetwork class.int
nbBooks()
Returns the number of books in the social network.int
nbFilms()
Returns the number of films in the social network.int
Returns the number of members in the social network.float
reviewItemBook
(String login, String password, String title, float mark, String comment) Reviews a book.float
reviewItemFilm
(String login, String password, String title, float mark, String comment) Reviews a film.toString()
Returns a string representation of this social network.
-
Constructor Details
-
SocialNetwork
public SocialNetwork()Constructs a new social network.
-
-
Method Details
-
getMembers
Gets the list of members in the social network.- Returns:
- the list of members in the social network
-
getItems
Gets the list of items in the social network.- Type Parameters:
T
- the type of item- Parameters:
itemType
- the type of item to retrieve (e.g., ItemBook.class, ItemFilm.class)- Returns:
- the list of items of the specified type in the social network
-
toString
-
nbMembers
public int nbMembers()Returns the number of members in the social network.- Specified by:
nbMembers
in interfaceopinion.ISocialNetwork
- Returns:
- the number of members in the social network
-
nbFilms
public int nbFilms()Returns the number of films in the social network.- Specified by:
nbFilms
in interfaceopinion.ISocialNetwork
- Returns:
- the number of films in the social network
-
nbBooks
public int nbBooks()Returns the number of books in the social network.- Specified by:
nbBooks
in interfaceopinion.ISocialNetwork
- Returns:
- the number of books in the social network
-
getMember
-
getItem
Gets an item by its title and type.- Type Parameters:
T
- the type of the item- Parameters:
title
- the title of the itemtype
- the type of the item (e.g., ItemBook.class, ItemFilm.class)- Returns:
- the item with the specified title and type, or null if not found
-
addMember
public void addMember(String login, String password, String profile) throws exceptions.BadEntryException, exceptions.MemberAlreadyExistsException Adds a new member to the social network.- Specified by:
addMember
in interfaceopinion.ISocialNetwork
- Parameters:
login
- the login of the memberpassword
- the password of the memberprofile
- the profile of the member- Throws:
exceptions.BadEntryException
- if the provided parameters are invalidexceptions.MemberAlreadyExistsException
- if a member with the same login already exists
-
addItemFilm
public void addItemFilm(String login, String password, String title, String kind, String director, String scriptwriter, int duration) throws exceptions.BadEntryException, exceptions.NotMemberException, exceptions.ItemFilmAlreadyExistsException Adds a new film to the social network.- Specified by:
addItemFilm
in interfaceopinion.ISocialNetwork
- Parameters:
login
- the login of the memberpassword
- the password of the membertitle
- the title of the filmkind
- the kind or genre of the filmdirector
- the director of the filmscriptwriter
- the scriptwriter of the filmduration
- the duration of the film in minutes- Throws:
exceptions.BadEntryException
- if the provided parameters are invalidexceptions.NotMemberException
- if the member doesn't existexceptions.ItemFilmAlreadyExistsException
- if a film with the same title already exists
-
addItemBook
public void addItemBook(String login, String password, String title, String kind, String author, int nbPages) throws exceptions.BadEntryException, exceptions.NotMemberException, exceptions.ItemBookAlreadyExistsException Adds a new book to the social network.- Specified by:
addItemBook
in interfaceopinion.ISocialNetwork
- Parameters:
login
- the login of the memberpassword
- the password of the membertitle
- the title of the bookkind
- the kind or genre of the bookauthor
- the author of the booknbPages
- the number of pages in the book- Throws:
exceptions.BadEntryException
- if the provided parameters are invalidexceptions.NotMemberException
- if the member doesn't existexceptions.ItemBookAlreadyExistsException
- if a book with the same title and author already exists
-
reviewItemFilm
public float reviewItemFilm(String login, String password, String title, float mark, String comment) throws exceptions.BadEntryException, exceptions.NotMemberException, exceptions.NotItemException Reviews a film.- Specified by:
reviewItemFilm
in interfaceopinion.ISocialNetwork
- Parameters:
login
- the login of the memberpassword
- the password of the membertitle
- the title of the filmmark
- the mark given to the filmcomment
- the comment on the film- Returns:
- the mean reviews of the film
- Throws:
exceptions.BadEntryException
- if the provided parameters are invalidexceptions.NotMemberException
- if the member doesn't existexceptions.NotItemException
- if the film doesn't exist
-
reviewItemBook
public float reviewItemBook(String login, String password, String title, float mark, String comment) throws exceptions.BadEntryException, exceptions.NotMemberException, exceptions.NotItemException Reviews a book.- Specified by:
reviewItemBook
in interfaceopinion.ISocialNetwork
- Parameters:
login
- the login of the memberpassword
- the password of the membertitle
- the title of the bookmark
- the mark given to the bookcomment
- the comment on the book- Returns:
- the mean reviews of the book
- Throws:
exceptions.BadEntryException
- if the provided parameters are invalidexceptions.NotMemberException
- if the member doesn't existexceptions.NotItemException
- if the book doesn't exist
-
consultItems
Consults items.- Specified by:
consultItems
in interfaceopinion.ISocialNetwork
- Parameters:
title
- the title of the item- Returns:
- a list of string representations of items with the specified title
- Throws:
exceptions.BadEntryException
- if the provided title is invalid
-
main
The main method of the SocialNetwork class.- Parameters:
args
- the arguments passed to the main method
-