1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| package fr.xxxx.yyyy;
import java.util.Enumeration;
import java.util.Hashtable;
import fr.xxxxxx.exceptions.SalarieException;
public class Application {
public static void main(String[] args) throws SalarieException {
Hashtable dict = new Hashtable();
Salarie s;
try {
s = new Salarie(5, 8, 14, "yyyyyyyyyyyyyyyyy", 1500);
Integer key = new Integer(s.getM_nMatricule());
dict.put(key, s);
/*
* s = new Salarie(3, 1, 20, "Isodore DUMARC", 10000); dict.put(key, s);
*
* s = new Commercial(6, 2, 30, "Mathieu LEBLOND", -17000, 52000, 9);
* dict.put(key, s);
*/
}
catch (SalarieException se)
{
System.err.println(se);
}
/**
* Ici on ajoute chaque élement dict.element() à l'Enumeration
*/
for (Enumeration e = dict.elements(); e.hasMoreElements() ;)
{
Salarie sal = (Salarie)e.nextElement();
System.out.println(sal);
System.out.println(sal.calculSalaire());
}
}
} |
Partager