import java.util.
ArrayList;
import java.util.Scanner;
class Joueur {
private String nom;
private int age;
private String pays;
private String club;
private double poids;
private double taille;
private String poste;
private int numero;
// Constructeur
public Joueur(String nom, int age, String pays, String club, double poids, double taille, String
poste, int numero) {
this.nom = nom;
this.age = age;
this.pays = pays;
this.club = club;
this.poids = poids;
this.taille = taille;
this.poste = poste;
this.numero = numero;
}
// Méthode pour véri er si le nom correspond
public boolean correspondNom(String nom) {
return this.nom.equalsIgnoreCase(nom);
}
// Méthode pour a cher les informations
public void a cherInformations() {
System.out.println("Nom : " + nom);
System.out.println("Âge : " + age + " ans");
System.out.println("Pays : " + pays);
System.out.println("Club : " + club);
System.out.println("Poids : " + poids + " kg");
System.out.println("Taille : " + taille + " m");
System.out.println("Poste : " + poste);
System.out.println("Numéro : " + numero);
}
}
public class Main {
public static void main(String[] args) {
// Liste des joueurs
ArrayList<Joueur> joueurs = new ArrayList<>();
joueurs.add(new Joueur("Lionel Messi", 36, "Argentine", "Inter Miami", 70, 1.70, "Attaquant",
10));
joueurs.add(new Joueur("Cristiano Ronaldo", 39, "Portugal", "Al-Nassr", 85, 1.87,
"Attaquant", 7));
joueurs.add(new Joueur("Kylian Mbappé", 25, "France", "Paris Saint-Germain", 75, 1.78,
"Attaquant", 7));
// Saisie du nom par l'utilisateur
Scanner scanner = new Scanner(System.in);
System.out.print("Entrez le nom du joueur : ");
String nomRecherche = scanner.nextLine();
ffi
ffi
fi
// Appel de la fonction pour a cher les informations
a cherInformationsJoueur(joueurs, nomRecherche);
scanner.close();
}
// Fonction pour a cher les informations d'un joueur
public static void a cherInformationsJoueur(ArrayList<Joueur> joueurs, String nom) {
boolean joueurTrouve = false;
for (Joueur joueur : joueurs) {
if (joueur.correspondNom(nom)) {
joueur.a cherInformations();
joueurTrouve = true;
break;
}
}
// Si le joueur n'est pas trouvé
if (!joueurTrouve) {
System.out.println("Désolé, le joueur '" + nom + "' n'a pas été trouvé.");
}
}
}
ffi
ffi
ffi
ffi
ffi