77 lines
1.5 KiB
Java
77 lines
1.5 KiB
Java
//
|
|
//
|
|
// Generated by StarUML(tm) Java Add-In
|
|
//
|
|
// @ Project : Untitled
|
|
// @ File Name : Pape.java
|
|
// @ Date : 19/12/2008
|
|
// @ Author :
|
|
//
|
|
//
|
|
|
|
|
|
|
|
|
|
public class Pape
|
|
{
|
|
private int numero;
|
|
private String prenom;
|
|
private static Pape lePape = null;
|
|
|
|
public static void main(String args[]){
|
|
Pape jp2 = new Pape("Jean - Paul", 2);
|
|
System.out.println(jp2.getNomPape());
|
|
Pape b16 = new Pape("Benoît", 16);
|
|
jp2.nommerPape(jp2.prenom, jp2.numero);
|
|
b16.nommerPape(b16.prenom, b16.numero);
|
|
System.out.println(b16.getNomPape());
|
|
}
|
|
|
|
public Pape(String nom, int num){
|
|
this.prenom = nom;
|
|
this.numero = num;
|
|
}
|
|
|
|
public static void nommerPape(String nom, int num)
|
|
{
|
|
if (lePape == null){
|
|
lePape = new Pape(nom, num);
|
|
System.out.println("Applaudissez la venue de " + nom + " " + num + " dans la Papautée.");
|
|
}
|
|
else {
|
|
System.out.println("Le pape existe déjà, " + nom + " " + num + " ne peut pas le devenir.");
|
|
}
|
|
}
|
|
|
|
public static Pape getPape()
|
|
{
|
|
return lePape;
|
|
}
|
|
|
|
public static String getNomPape()
|
|
{
|
|
if(lePape != null){
|
|
return "Pape actuel: " + lePape.prenom + " " + lePape.numero;
|
|
}
|
|
else {
|
|
return "Aucun pape n'a été nommé.";
|
|
}
|
|
}
|
|
|
|
public static void mortDuPape()
|
|
{
|
|
if(lePape != null){
|
|
lePape = null;
|
|
}
|
|
else {
|
|
System.out.println("Il n'existe pas de Pape actuellement !");
|
|
}
|
|
}
|
|
|
|
public String getNom()
|
|
{
|
|
String nomPape = new String(this.prenom + this.numero);
|
|
return nomPape;
|
|
}
|
|
}
|