MàJ par récupération sur Clé USB et dans /mnt/hd/Chargement du pc portable
This commit is contained in:
262
G5a/Solutions/3-exosClasses-1/1-Adherent/Adherent.java
Normal file
262
G5a/Solutions/3-exosClasses-1/1-Adherent/Adherent.java
Normal file
@ -0,0 +1,262 @@
|
||||
|
||||
/** Java class "Adherent.java" generated from Poseidon for UML.
|
||||
* Poseidon for UML is developed by <A HREF="http://www.gentleware.com">Gentleware</A>.
|
||||
* Generated with <A HREF="http://jakarta.apache.org/velocity/">velocity</A> template engine.
|
||||
*/
|
||||
package adherents;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*/
|
||||
public class Adherent {
|
||||
|
||||
///////////////////////////////////////
|
||||
// attributes
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represents ...
|
||||
* </p>
|
||||
*/
|
||||
private int numeroAdherent;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represents ...
|
||||
* </p>
|
||||
*/
|
||||
private String nom;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represents ...
|
||||
* </p>
|
||||
*/
|
||||
private String ville;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represents ...
|
||||
* </p>
|
||||
*/
|
||||
private int anneeNaissance;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represente le montant de la cotisation (commun à tous les adherents)
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
private static int c_montantCotisation=45;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represente le montant actuellement verse par l'adherent
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
private int cotisationVersee;
|
||||
|
||||
///////////////////////////////////////
|
||||
// operations
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Does ...
|
||||
* </p><p>
|
||||
*
|
||||
* @return a String with ...
|
||||
* </p>
|
||||
*/
|
||||
public String getNom() {
|
||||
// your code here
|
||||
return this.nom;
|
||||
} // end getNom
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represents ...
|
||||
* </p>
|
||||
*/
|
||||
public int getNumeroAdh() {
|
||||
return this.numeroAdherent;
|
||||
} // end getNumeroAdh
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Does ...
|
||||
* </p><p>
|
||||
*
|
||||
* @return a int with ...
|
||||
* </p>
|
||||
*/
|
||||
public int getAge() {
|
||||
// your code here
|
||||
return 2005-anneeNaissance;
|
||||
} // end getAge
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represents ...
|
||||
* </p>
|
||||
*/
|
||||
public int getCotisationVersee() {
|
||||
return cotisationVersee;
|
||||
} // end getCotisationVersee
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* @return a boolean : l'adherent est ou non à jour de cotisation
|
||||
* </p>
|
||||
*/
|
||||
public boolean aJour() {
|
||||
// your code here
|
||||
if (cotisationVersee>=c_montantCotisation)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
||||
} // end aJour
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Ajoute la somme passee en param au montant de la cotisation versee
|
||||
* </p>
|
||||
* <p>
|
||||
*
|
||||
* @return a boolean qui dit si l'adherent est a jour apres ce versement
|
||||
* </p>
|
||||
* <p>
|
||||
* @param versement montant de la somme versee
|
||||
* </p>
|
||||
*/
|
||||
public boolean cotiser(int versement) {
|
||||
// your code here
|
||||
cotisationVersee+=versement;
|
||||
return aJour();
|
||||
} // end cotiser
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* @return a String : "A jour" ou " PAS A JOUR !!!"
|
||||
* </p>
|
||||
*/
|
||||
public String etat() {
|
||||
// your code here
|
||||
String etat;
|
||||
if (this.aJour()) etat = "a jour"; else etat = "PAS A JOUR !!!";
|
||||
return etat;
|
||||
} // end etat
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Does ...
|
||||
* </p><p>
|
||||
*
|
||||
* @return a String with ...
|
||||
* </p>
|
||||
*/
|
||||
public String toString() {
|
||||
// your code here
|
||||
return (getNumeroAdh()+" "+getNom()+" "+getVille()+" "+getAge()+" ans : a cotise : "+getCotisationVersee()+" "+etat());
|
||||
} // end toString
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Does ...
|
||||
* </p><p>
|
||||
*
|
||||
* </p><p>
|
||||
*
|
||||
* @param args ...
|
||||
* </p>
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
// your code here
|
||||
Adherent a1=new Adherent(1,"Dupont","Paris",1980);
|
||||
Adherent a2=new Adherent(2,"Meyer","Strasbourg",1955);
|
||||
Adherent a3=new Adherent(3,"Legwenn","Brest",1960);
|
||||
System.out.println (a1);
|
||||
System.out.println (a2);
|
||||
System.out.println (a3);
|
||||
System.out.println ();
|
||||
a1.cotiser(45);
|
||||
System.out.println (a1);
|
||||
System.out.println (a2);
|
||||
System.out.println (a3);
|
||||
System.out.println ();
|
||||
a2.cotiser(30);
|
||||
System.out.println (a1);
|
||||
System.out.println (a2);
|
||||
System.out.println (a3);
|
||||
System.out.println ();
|
||||
a3.cotiser(40);
|
||||
System.out.println (a1);
|
||||
System.out.println (a2);
|
||||
System.out.println (a3);
|
||||
System.out.println ();
|
||||
a2.cotiser(15);
|
||||
System.out.println (a1);
|
||||
System.out.println (a2);
|
||||
System.out.println (a3);
|
||||
} // end main
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Constructeur d'Adherent
|
||||
* </p>
|
||||
* <p>
|
||||
*
|
||||
* @return a Adherent
|
||||
* </p>
|
||||
* <p>
|
||||
* @param num ...
|
||||
* </p>
|
||||
* <p>
|
||||
* @param nom ...
|
||||
* </p>
|
||||
* <p>
|
||||
* @param vil ...
|
||||
* </p>
|
||||
* <p>
|
||||
* @param nss ...
|
||||
* </p>
|
||||
*/
|
||||
public Adherent(int num, String nom, String vil, int nss) {
|
||||
// your code here
|
||||
this.numeroAdherent=num;
|
||||
this.nom=nom;
|
||||
this.ville=vil;
|
||||
this.anneeNaissance=nss;
|
||||
} // end Adherent
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represents ...
|
||||
* </p>
|
||||
*/
|
||||
public String getVille() {
|
||||
return ville;
|
||||
} // end getVille
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represents ...
|
||||
* </p>
|
||||
*/
|
||||
public void setVille(String _ville) {
|
||||
ville = _ville;
|
||||
} // end setVille
|
||||
|
||||
} // end Adherent
|
||||
|
||||
|
||||
|
66
G5a/Solutions/3-exosClasses-1/1-Adherent/Gerant.java
Normal file
66
G5a/Solutions/3-exosClasses-1/1-Adherent/Gerant.java
Normal file
@ -0,0 +1,66 @@
|
||||
|
||||
/** Java class "Gerant.java" generated from Poseidon for UML.
|
||||
* Poseidon for UML is developed by <A HREF="http://www.gentleware.com">Gentleware</A>.
|
||||
* Generated with <A HREF="http://jakarta.apache.org/velocity/">velocity</A> template engine.
|
||||
*/
|
||||
package adherents;
|
||||
|
||||
import adherents.Adherent;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*/
|
||||
class Gerant {
|
||||
|
||||
///////////////////////////////////////
|
||||
// operations
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Does ...
|
||||
* </p><p>
|
||||
*
|
||||
* </p><p>
|
||||
*
|
||||
* @param args ...
|
||||
* </p>
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
|
||||
// your code here
|
||||
Adherent a1=new Adherent(1,"Dupont","Paris",1980);
|
||||
Adherent a2=new Adherent(2,"Meyer","Strasbourg",1955);
|
||||
Adherent a3=new Adherent(3,"Legwenn","Brest",1960);
|
||||
System.out.println (a1);
|
||||
System.out.println (a2);
|
||||
System.out.println (a3);
|
||||
System.out.println ();
|
||||
a1.cotiser(45);
|
||||
System.out.println (a1);
|
||||
System.out.println (a2);
|
||||
System.out.println (a3);
|
||||
System.out.println ();
|
||||
a2.cotiser(30);
|
||||
System.out.println (a1);
|
||||
System.out.println (a2);
|
||||
System.out.println (a3);
|
||||
System.out.println ();
|
||||
a3.cotiser(40);
|
||||
System.out.println (a1);
|
||||
System.out.println (a2);
|
||||
System.out.println (a3);
|
||||
System.out.println ();
|
||||
a2.cotiser(15);
|
||||
System.out.println (a1);
|
||||
System.out.println (a2);
|
||||
System.out.println (a3);
|
||||
} // end main
|
||||
|
||||
} // end Gerant
|
||||
|
||||
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 41 KiB |
@ -0,0 +1,263 @@
|
||||
|
||||
/** Java class "Adherent.java" generated from Poseidon for UML.
|
||||
* Poseidon for UML is developed by <A HREF="http://www.gentleware.com">Gentleware</A>.
|
||||
* Generated with <A HREF="http://jakarta.apache.org/velocity/">velocity</A> template engine.
|
||||
*/
|
||||
package Pack_adherents;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*/
|
||||
public class Adherent {
|
||||
|
||||
///////////////////////////////////////
|
||||
// attributes
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represents ...
|
||||
* </p>
|
||||
*/
|
||||
private int numeroAdherent;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represents ...
|
||||
* </p>
|
||||
*/
|
||||
private String nom;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represents ...
|
||||
* </p>
|
||||
*/
|
||||
private String ville;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represents ...
|
||||
* </p>
|
||||
*/
|
||||
private int anneeNaissance;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represente le montant de la cotisation (commun à tous les adherents)
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
private static int c_montantCotisation=45;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represente le montant actuellement verse par l'adherent
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
private int cotisationVersee;
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// operations
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Does ...
|
||||
* </p><p>
|
||||
*
|
||||
* @return a String with ...
|
||||
* </p>
|
||||
*/
|
||||
public String getNom() {
|
||||
// your code here
|
||||
return this.nom;
|
||||
} // end getNom
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represents ...
|
||||
* </p>
|
||||
*/
|
||||
public int getNumeroAdh() {
|
||||
return this.numeroAdherent;
|
||||
} // end getNumeroAdh
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Does ...
|
||||
* </p><p>
|
||||
*
|
||||
* @return a int with ...
|
||||
* </p>
|
||||
*/
|
||||
public int getAge() {
|
||||
// your code here
|
||||
return 2005-anneeNaissance;
|
||||
} // end getAge
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represents ...
|
||||
* </p>
|
||||
*/
|
||||
public int getCotisationVersee() {
|
||||
return cotisationVersee;
|
||||
} // end getCotisationVersee
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* @return a boolean : l'adherent est ou non à jour de cotisation
|
||||
* </p>
|
||||
*/
|
||||
public boolean aJour() {
|
||||
// your code here
|
||||
if (cotisationVersee>=c_montantCotisation)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
||||
} // end aJour
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Ajoute la somme passee en param au montant de la cotisation versee
|
||||
* </p>
|
||||
* <p>
|
||||
*
|
||||
* @return a boolean qui dit si l'adherent est a jour apres ce versement
|
||||
* </p>
|
||||
* <p>
|
||||
* @param versement montant de la somme versee
|
||||
* </p>
|
||||
*/
|
||||
public boolean cotiser(int versement) {
|
||||
// your code here
|
||||
cotisationVersee+=versement;
|
||||
return aJour();
|
||||
} // end cotiser
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* @return a String : "A jour" ou " PAS A JOUR !!!"
|
||||
* </p>
|
||||
*/
|
||||
public String etat() {
|
||||
// your code here
|
||||
String etat;
|
||||
if (this.aJour()) etat = "a jour"; else etat = "PAS A JOUR !!!";
|
||||
return etat;
|
||||
} // end etat
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Does ...
|
||||
* </p><p>
|
||||
*
|
||||
* @return a String with ...
|
||||
* </p>
|
||||
*/
|
||||
public String toString() {
|
||||
// your code here
|
||||
return (getNumeroAdh()+" "+getNom()+" "+getVille()+" "+getAge()+" ans : a cotise : "+getCotisationVersee()+" "+etat());
|
||||
} // end toString
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Does ...
|
||||
* </p><p>
|
||||
*
|
||||
* </p><p>
|
||||
*
|
||||
* @param args ...
|
||||
* </p>
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
// your code here
|
||||
Adherent a1=new Adherent(1,"Dupont","Paris",1980);
|
||||
Adherent a2=new Adherent(2,"Meyer","Strasbourg",1955);
|
||||
Adherent a3=new Adherent(3,"Legwenn","Brest",1960);
|
||||
System.out.println (a1);
|
||||
System.out.println (a2);
|
||||
System.out.println (a3);
|
||||
System.out.println ();
|
||||
a1.cotiser(45);
|
||||
System.out.println (a1);
|
||||
System.out.println (a2);
|
||||
System.out.println (a3);
|
||||
System.out.println ();
|
||||
a2.cotiser(30);
|
||||
System.out.println (a1);
|
||||
System.out.println (a2);
|
||||
System.out.println (a3);
|
||||
System.out.println ();
|
||||
a3.cotiser(40);
|
||||
System.out.println (a1);
|
||||
System.out.println (a2);
|
||||
System.out.println (a3);
|
||||
System.out.println ();
|
||||
a2.cotiser(15);
|
||||
System.out.println (a1);
|
||||
System.out.println (a2);
|
||||
System.out.println (a3);
|
||||
} // end main
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Constructeur d'Adherent
|
||||
* </p>
|
||||
* <p>
|
||||
*
|
||||
* @return a Adherent
|
||||
* </p>
|
||||
* <p>
|
||||
* @param num ...
|
||||
* </p>
|
||||
* <p>
|
||||
* @param nom ...
|
||||
* </p>
|
||||
* <p>
|
||||
* @param vil ...
|
||||
* </p>
|
||||
* <p>
|
||||
* @param nss ...
|
||||
* </p>
|
||||
*/
|
||||
public Adherent(int num, String nom, String vil, int nss) {
|
||||
// your code here
|
||||
this.numeroAdherent=num;
|
||||
this.nom=nom;
|
||||
this.ville=vil;
|
||||
this.anneeNaissance=nss;
|
||||
} // end Adherent
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represents ...
|
||||
* </p>
|
||||
*/
|
||||
public String getVille() {
|
||||
return ville;
|
||||
} // end getVille
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represents ...
|
||||
* </p>
|
||||
*/
|
||||
public void setVille(String _ville) {
|
||||
ville = _ville;
|
||||
} // end setVille
|
||||
|
||||
} // end Adherent
|
||||
|
||||
|
||||
|
@ -0,0 +1,134 @@
|
||||
|
||||
/** Java class "Gerant.java" generated from Poseidon for UML.
|
||||
* Poseidon for UML is developed by <A HREF="http://www.gentleware.com">Gentleware</A>.
|
||||
* Generated with <A HREF="http://jakarta.apache.org/velocity/">velocity</A> template engine.
|
||||
*/
|
||||
package Pack_adherents;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*/
|
||||
class Gerant {
|
||||
|
||||
///////////////////////////////////////
|
||||
// attributes
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*/
|
||||
public static Collection adherent = new Vector();
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// operations
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Does ...
|
||||
* </p><p>
|
||||
*
|
||||
* </p><p>
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param args ...
|
||||
* </p>
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
|
||||
|
||||
|
||||
|
||||
Adherent a1=new Adherent(1,"Dupont","Paris",1980);
|
||||
addAdherent(a1);
|
||||
Adherent a2=new Adherent(2,"Meyer","Strasbourg",1955);
|
||||
addAdherent(a2);
|
||||
Adherent a3=new Adherent(3,"Legwenn","Brest",1960);
|
||||
addAdherent(a3);
|
||||
for (int i=0;i<adherent.size();i++){
|
||||
Vector v=(Vector)getAdherents();
|
||||
Adherent a=(Adherent)v.elementAt(i);
|
||||
System.out.println (a);
|
||||
}
|
||||
System.out.println ();
|
||||
a1.cotiser(45);
|
||||
for (int i=0;i<adherent.size();i++){
|
||||
Vector v=(Vector)getAdherents();
|
||||
Adherent a=(Adherent)v.elementAt(i);
|
||||
System.out.println (a);
|
||||
}
|
||||
System.out.println ();
|
||||
a2.cotiser(30);
|
||||
for (int i=0;i<adherent.size();i++){
|
||||
Vector v=(Vector)getAdherents();
|
||||
Adherent a=(Adherent)v.elementAt(i);
|
||||
System.out.println (a);
|
||||
}
|
||||
System.out.println ();
|
||||
a3.cotiser(40);
|
||||
for (int i=0;i<adherent.size();i++){
|
||||
Vector v=(Vector)getAdherents();
|
||||
Adherent a=(Adherent)v.elementAt(i);
|
||||
System.out.println (a);
|
||||
}
|
||||
System.out.println ();
|
||||
a2.cotiser(15);
|
||||
for (int i=0;i<adherent.size();i++){
|
||||
Vector v=(Vector)getAdherents();
|
||||
Adherent a=(Adherent)v.elementAt(i);
|
||||
System.out.println (a);
|
||||
}
|
||||
} // end main
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Does ...
|
||||
* </p><p>
|
||||
*
|
||||
* @return a Collection with ...
|
||||
* </p>
|
||||
*/
|
||||
public static Collection getAdherents() {
|
||||
return adherent;
|
||||
} // end getAdherents
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Does ...
|
||||
* </p><p>
|
||||
*
|
||||
* </p><p>
|
||||
*
|
||||
* @param adherent ...
|
||||
* </p>
|
||||
*/
|
||||
public static void addAdherent(Adherent adherent) {
|
||||
if (! Gerant.adherent.contains(adherent)) Gerant.adherent.add(adherent);
|
||||
} // end addAdherent
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Does ...
|
||||
* </p><p>
|
||||
*
|
||||
* </p><p>
|
||||
*
|
||||
* @param adherent ...
|
||||
* </p>
|
||||
*/
|
||||
public static void removeAdherent(Adherent adherent) {
|
||||
Gerant.adherent.remove(adherent);
|
||||
} // end removeAdherent
|
||||
|
||||
} // end Gerant
|
||||
|
||||
|
||||
|
21
G5a/Solutions/3-exosClasses-1/3-PersonneFemme/Femme.java
Normal file
21
G5a/Solutions/3-exosClasses-1/3-PersonneFemme/Femme.java
Normal file
@ -0,0 +1,21 @@
|
||||
|
||||
|
||||
public class Femme extends Personne {
|
||||
|
||||
///////////////////////////////////////
|
||||
// attributes
|
||||
private String nomjf;
|
||||
|
||||
///////////////////////////////////////
|
||||
// operations
|
||||
public Femme(String nom,int an, String njf) {
|
||||
super(nom,an);
|
||||
this.nomjf = njf;
|
||||
} // end constructeur
|
||||
public String toString(){
|
||||
return super.toString()+" nee "+nomjf;
|
||||
}
|
||||
} // end Femme
|
||||
|
||||
|
||||
|
54
G5a/Solutions/3-exosClasses-1/3-PersonneFemme/Personne.java
Normal file
54
G5a/Solutions/3-exosClasses-1/3-PersonneFemme/Personne.java
Normal file
@ -0,0 +1,54 @@
|
||||
|
||||
/** Java class "Personne.java"
|
||||
Repr<EFBFBD>sente une personne quelconque
|
||||
*/
|
||||
import java.util.*;
|
||||
public class Personne {
|
||||
|
||||
///////////////////////////////////////
|
||||
// attributes
|
||||
|
||||
private String nom;
|
||||
private int anneeNaiss;
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// operations
|
||||
|
||||
public String getNom() {
|
||||
return nom;
|
||||
}
|
||||
public void setNom(String _nom) {
|
||||
nom = _nom;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Constructeur de Personne
|
||||
* </p><p>
|
||||
*
|
||||
* @return a Personne * </p><p>
|
||||
* @param i identifiant
|
||||
* </p> <p>
|
||||
* @param n nom
|
||||
* </p>
|
||||
*/
|
||||
public Personne(String n,int an) {
|
||||
this.nom=n;
|
||||
this.anneeNaiss=an;
|
||||
}
|
||||
public String toString() {
|
||||
return nom+" "+anneeNaiss;
|
||||
}
|
||||
public static void main (String args[]) {
|
||||
Personne p1 = new Personne("Dupont", 1964);
|
||||
Personne p2 = new Personne("Dulac", 1983);
|
||||
Personne p3 = new Femme("Mme Dupont", 1972,"Durand");
|
||||
System.out.println (p1);
|
||||
System.out.println (p2);
|
||||
System.out.println (p3);
|
||||
}
|
||||
} // end Personne
|
||||
|
||||
|
||||
|
79
G5a/Solutions/3-exosClasses-1/4-Confiture/Confiture.java
Normal file
79
G5a/Solutions/3-exosClasses-1/4-Confiture/Confiture.java
Normal file
@ -0,0 +1,79 @@
|
||||
public class Confiture {
|
||||
|
||||
// Attributs
|
||||
private String cuisinier, parfum;
|
||||
private int annee;
|
||||
private int id;
|
||||
private static int c_nextId=1;
|
||||
|
||||
|
||||
// Constructeur
|
||||
public Confiture ( String parfum, String cuisinier,int an ) {
|
||||
this.parfum = parfum;
|
||||
this.cuisinier = cuisinier;
|
||||
this.annee = an;
|
||||
this.id=c_nextId++;
|
||||
|
||||
}
|
||||
|
||||
// Accesseurs
|
||||
public String getCuisinier() {
|
||||
return this.cuisinier;
|
||||
}
|
||||
|
||||
public String getParfum() {
|
||||
return this.parfum;
|
||||
}
|
||||
|
||||
public int getAnnee() {
|
||||
return this.annee;
|
||||
}
|
||||
|
||||
// Modificateurs
|
||||
public void setAnnee( int annee ) {
|
||||
if ( annee >= 0 )
|
||||
this.annee = annee;
|
||||
else
|
||||
System.err.println( "Attention ! l'ann<6E>e entr<74>e n'est pas valide" );
|
||||
}
|
||||
|
||||
public void setCuisinier( String cuisinier ) {
|
||||
this.cuisinier = cuisinier;
|
||||
}
|
||||
|
||||
public void setParfum( String parfum ) {
|
||||
this.parfum = parfum;
|
||||
}
|
||||
|
||||
|
||||
// M<>thode d'affichage
|
||||
public String toString() {
|
||||
StringBuffer infos = new StringBuffer(" ");
|
||||
infos.append(this.id);
|
||||
infos.append(" : Confiture de ").append(this.parfum);
|
||||
infos.append(" par ").append(this.cuisinier);
|
||||
infos.append(" (").append(this.annee).append(")");
|
||||
String res=new String(infos);
|
||||
return res;
|
||||
}
|
||||
|
||||
public static void main( String args[] ) {
|
||||
|
||||
// Creation des deux confitures
|
||||
Confiture conf1 = new Confiture("fraise","Maman",2007 );
|
||||
Confiture conf2 = new Confiture("framboise","Moi",2006 );
|
||||
Confiture conf3 = new Confiture("cassis","Meme",2003 );
|
||||
|
||||
// Modification d'une ann<6E>e
|
||||
conf2.setAnnee( 2005 );
|
||||
|
||||
// Affichage des cuisiniers
|
||||
System.out.println( "Cuisinier confiture 1 : " + conf1.getCuisinier() );
|
||||
System.out.println( "Cuisinier confiture 2 : " + conf2.getCuisinier() );
|
||||
|
||||
// Affichage des informations sur la confiture par la m<>thode println
|
||||
System.out.println( conf1 );
|
||||
System.out.println( conf2 );
|
||||
System.out.println( conf3 );
|
||||
}
|
||||
}
|
BIN
G5a/Solutions/3-exosClasses-1/4-Confiture/confiture.jpg
Normal file
BIN
G5a/Solutions/3-exosClasses-1/4-Confiture/confiture.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
Reference in New Issue
Block a user