Constructeur java et ses parametres
Résolu/Fermé
A voir également:
- Constructeur java et ses parametres
- Java apk - Télécharger - Langages
- Telecharger java - Télécharger - Langages
- Jeux java itel - Forum Mobile
- Scanf en java ✓ - Forum Java
- Comment faire pour installer des jeux java sur téléphone portable ? ✓ - Forum Jeux vidéo
3 réponses
KX
Messages postés
16722
Date d'inscription
samedi 31 mai 2008
Statut
Modérateur
Dernière intervention
25 septembre 2023
3 014
Modifié par KX le 10/12/2011 à 17:45
Modifié par KX le 10/12/2011 à 17:45
Si je comprends bien ton problème c'est assez simple. Exemple :
Evidemment, il faut réutiliser ça avec ton exemple de classe Sportif.La confiance n'exclut pas le contrôle
public class Point { private int x; private int y; public Point(int x,int y) { this.x=x; this.y=y; } public int x() { return x; } public int y() { return y; } }
Evidemment, il faut réutiliser ça avec ton exemple de classe Sportif.La confiance n'exclut pas le contrôle
Wissem FEZZANI
Messages postés
7
Date d'inscription
samedi 10 décembre 2011
Statut
Membre
Dernière intervention
12 décembre 2011
10 déc. 2011 à 18:13
10 déc. 2011 à 18:13
Bonjour,
la solution ce n'est que créer un objet de type sportif, récupérer les paramètres dedans lors de la lecture, puis faire affectation de cet objet dans l'instance que vous voudriez créer.
la solution ce n'est que créer un objet de type sportif, récupérer les paramètres dedans lors de la lecture, puis faire affectation de cet objet dans l'instance que vous voudriez créer.
voici mon code:
public class Entraineur {
private String name;
private String firstName;
private int ident;
private String dateOfBirth;
private String placeOfBirth;
private String adress;
private String phoneNumber;
private String dateInscription;
public Entraineur(int ident,String name,String firstName,String dateOfBirth,String placeOfBirth,String adress,String phoneNumber,String dateInscription){
this.name=name;
this.firstName=firstName;
this.dateOfBirth=dateOfBirth;
this.placeOfBirth=placeOfBirth;
this.adress=adress;
this.phoneNumber=phoneNumber;
this.dateInscription=dateInscription;
this.ident=ident;
}
public String getName(){
return name;
}
public String getFirstName(){
return firstName;
}
public int getIdent(){
return ident;
}
public String getDateOfBirth(){
return dateOfBirth;
}
public String getPlaceOfBirth(){
return placeOfBirth;
}
public String getAdress(){
return adress;
}
public String getPhoneNumber(){
return phoneNumber;
}
public String toString(){
return ident + "/" + firstName + "/" + dateOfBirth + "/" + placeOfBirth + "/" + "/" + placeOfBirth
+ "/" + adress + "/" + phoneNumber;
}
}
public class Entraineur {
private String name;
private String firstName;
private int ident;
private String dateOfBirth;
private String placeOfBirth;
private String adress;
private String phoneNumber;
private String dateInscription;
public Entraineur(int ident,String name,String firstName,String dateOfBirth,String placeOfBirth,String adress,String phoneNumber,String dateInscription){
this.name=name;
this.firstName=firstName;
this.dateOfBirth=dateOfBirth;
this.placeOfBirth=placeOfBirth;
this.adress=adress;
this.phoneNumber=phoneNumber;
this.dateInscription=dateInscription;
this.ident=ident;
}
public String getName(){
return name;
}
public String getFirstName(){
return firstName;
}
public int getIdent(){
return ident;
}
public String getDateOfBirth(){
return dateOfBirth;
}
public String getPlaceOfBirth(){
return placeOfBirth;
}
public String getAdress(){
return adress;
}
public String getPhoneNumber(){
return phoneNumber;
}
public String toString(){
return ident + "/" + firstName + "/" + dateOfBirth + "/" + placeOfBirth + "/" + "/" + placeOfBirth
+ "/" + adress + "/" + phoneNumber;
}
}
10 déc. 2011 à 18:07
10 déc. 2011 à 18:15
10 déc. 2011 à 18:24
10 déc. 2011 à 18:29
Testes ce programme pour voir ce qu'il fait, normalement tu auras quelque chose comme ça (je mets en italique gras ce que l'utilisateur entre au clavier)
10 déc. 2011 à 18:36