cours0708/G5a/Solutions/3-exosClasses-1/2-AdherentGerant/Pack_adherents/Adherent.java

264 lines
4.9 KiB
Java

/** 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 &#224; 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 &#224; 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 : &quot;A jour&quot; ou &quot; PAS A JOUR !!!&quot;
* </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