Bonjour
Je ne comprend pa l'erreur que j'obtient avec l'exception SalarieException :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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());
        }
 
 
	}
 
 
}
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 
package fr.xxxx.exceptions;
 
 
import fr.xxxx.yyyy.Salarie;
 
 
public class SalarieException extends Exception {
 
 
	public SalarieException(Salarie salarie){
		super();
	}
 
	public String toString() {
 
		return super.toString() + 
				"\nLe salaire ne peut être que positif.";
	}
 
}
L'erreur se trouve à la ligne 30 à :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
catch (SalarieException se)