nikelllllllll

This commit is contained in:
Qpelu 2025-04-09 17:03:01 +02:00
parent 207b5ef807
commit 7e7fae17ef
2 changed files with 9 additions and 10 deletions

View File

@ -7,7 +7,7 @@ import java.util.ArrayList;
import java.util.List;
public class ListeAvis {
private static List<Avis> listeAvis;
private List<Avis> listeAvis;
public ListeAvis(String csvPath) {
listeAvis = new ArrayList<>();
@ -67,7 +67,7 @@ public class ListeAvis {
}
public static List<String> getCommentairesParFilm(int numeroFilm) {
public List<String> getCommentairesParFilm(int numeroFilm) {
List<String> commentaires = new ArrayList<>();
for (Avis avis : listeAvis) {

View File

@ -38,6 +38,8 @@ public class inter extends JFrame {
private JPanel panel;
private JButton entreeButton;
private ListeAvis listeAvis;
// Cache des données
private final Map<Integer, List<String>> commentairesFilms = new HashMap<>();
private final Map<Integer, Integer> notesFilms = new HashMap<>();
@ -61,6 +63,7 @@ public class inter extends JFrame {
* Create the frame.
*/
public inter() {
listeAvis = new ListeAvis("C:\\\\Users\\\\Qpelu\\\\Downloads\\\\big.csv\\");
initialiserDictionnaireSentiments();
initialiserInterface();
}
@ -198,7 +201,7 @@ public class inter extends JFrame {
int totalNotes= 0;
Dictionnaire dico=new Dictionnaire("C:\\Users\\Qpelu\\Downloads\\dictionnaire.csv");
totalNotes += Avis.Analyse(ListeAvis.getCommentairesParFilm(filmNumber), dico);
totalNotes += Avis.Analyse(listeAvis.getCommentairesParFilm(filmNumber), dico);
System.out.println(totalNotes);
@ -233,12 +236,9 @@ public class inter extends JFrame {
JPanel centralPanel = new JPanel();
centralPanel.setLayout(new GridLayout(1, 2, MARGIN, 0));
// Initialiser la liste des commentaires si nécessaire
if (!commentairesFilms.containsKey(filmNumber)) {
commentairesFilms.put(filmNumber, new ArrayList<>());
}
List<String> commentaires = commentairesFilms.get(filmNumber);
List<String> commentaires = listeAvis.getCommentairesParFilm(filmNumber);
// Panel pour la note et les commentaires affichés
JPanel notePanel = creerPanelNote(filmNumber, commentaires);
@ -392,9 +392,8 @@ public class inter extends JFrame {
*/
private void ajouterCommentaire(int filmNumber, String c) {
// Récupérer la liste des commentaires
ListeAvis lavis = new ListeAvis("C:\\Users\\Qpelu\\Downloads\\big.csv");
Dictionnaire dico = new Dictionnaire("C:\\Users\\Qpelu\\Downloads\\dictionnaire.csv");
List<String> commentaires = ListeAvis.getCommentairesParFilm(filmNumber);
List<String> commentaires = listeAvis.getCommentairesParFilm(filmNumber);
commentaires.add(c);
// Calculer la nouvelle note moyenne