0% found this document useful (0 votes)
3 views3 pages

Examen JAVA

Uploaded by

HOMEROS FF
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

Examen JAVA

Uploaded by

HOMEROS FF
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Examen JAVA :

Exercice :
1) - class Joueur {
private int adh;
private String nom;
private String prenom;
private int annee;
private int age;

public Joueur(int adh) {


this.adh = adh;
}

private String clavier() {


return new Scanner(System.in).nextLine();
}

public void lecture() {


System.out.print("Enter last name: ");
this.nom = clavier();

System.out.print("Enter first name: ");


this.prenom = clavier();

System.out.print("Enter year of joining: ");


this.annee = Integer.parseInt(clavier());

System.out.print("Enter age: ");


this.age = Integer.parseInt(clavier());
}

public void affichage() {


System.out.println("\nMember Details:");
System.out.println("Number: " + adh);
System.out.println("Name: " + prenom + " " + nom);
System.out.println("Year: " + annee);
System.out.println("Age: " + age);
}
public int getAge() {
return age;
}
}

2) - class Club {
private int max;
private Joueur[] table;
private int nbe;

public Club(int max, int initialMembers) {


this.max = max;
this.nbe = initialMembers;
this.table = new Joueur[max];
}

public boolean ajoutejoueur(Joueur j) {


if(nbe < max) {
table[nbe] = j;
nbe++;
return true;
}
return false;
}

public void afficher() {


System.out.println("\nClub Members List:");
for(int i = 0; i < nbe; i++) {
table[i].affichage();
}
}

public void rechercher(int deb, int fin) {


System.out.println("\nSearch Results (" + deb + "-" + fin + " years):");
for(int i = 0; i < nbe; i++) {
if(table[i].getAge() >= deb && table[i].getAge() <= fin) {
table[i].affichage();
}
}
}
}

3) - public class FootballClubManagement {


public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

Club myClub = new Club(5, 0);

for(int i = 0; i < 3; i++) {


System.out.println("\nRegistering new member #" + (i+1));
System.out.print("Enter member number: ");
int memberNumber = scanner.nextInt();
scanner.nextLine();

Joueur newPlayer = new Joueur(memberNumber);


newPlayer.lecture();

if(myClub.ajoutejoueur(newPlayer)) {
System.out.println("Member added successfully!");
} else {
System.out.println("Club is full!");
}
}
myClub.afficher();

System.out.println("\nSearch by age range");


System.out.print("Enter minimum age: ");
int minAge = scanner.nextInt();
System.out.print("Enter maximum age: ");
int maxAge = scanner.nextInt();
myClub.rechercher(minAge, maxAge);

scanner.close();
}
}

You might also like