TP-programmation-orientee-o.../TP09/ObjetNomme.java

33 lines
585 B
Java
Raw Normal View History

2023-06-20 19:02:09 +00:00
/**
* Un objet nommé est un objet qui a un nom.
*/
public abstract class ObjetNomme {
private String nom;
/**
* Initialiser le nom de l'agenda.
*
* @param nom le nom de l'agenda
* @throws IllegalArgumentException si nom n'a pas au moins un caractère
*/
public ObjetNomme(String nom) throws IllegalArgumentException {
if (nom == null || nom.length() < 1) {
throw new IllegalArgumentException();
} else {
this.nom = nom;
}
}
/**
* Obtenir le nom de cet objet.
* @return le nom de cet objet
*/
public String getNom() {
return this.nom;
}
}