diff --git a/cbindex.html b/cbindex.html
new file mode 100644
index 0000000..b1fb22e
--- /dev/null
+++ b/cbindex.html
@@ -0,0 +1,256 @@
+
+
+
+
+
+
+ Java Visualizer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/example-code/GCExample.java b/example-code/GCExample.java
new file mode 100644
index 0000000..23874ff
--- /dev/null
+++ b/example-code/GCExample.java
@@ -0,0 +1,12 @@
+import studsctrs.Personne;
+public class GCExample {
+ public static void main(String[] args) {
+ Personne c1 = null;
+ Personne c2 = new Personne("vide", "vide");
+ System.out.println(c2);
+ c1 = c2; // c1 duplicates last c2
+ c2 = null; // c2 not valid c1 references object
+ c1 = null; // c1 forgets reference to object
+ System.gc();
+ }
+}
\ No newline at end of file
diff --git a/example-code/HashMapExample.java b/example-code/HashMapExample.java
new file mode 100644
index 0000000..d305954
--- /dev/null
+++ b/example-code/HashMapExample.java
@@ -0,0 +1,16 @@
+import java.util.Hashtable;
+import java.util.Map;
+public class HashMapExample{
+ public static void main(final String argv[]) {
+ Map ht = new Hashtable();
+ ht.put("Ba", "Bah"); ht.put("Aa", "aha");
+ ht.put("BB", "bebe");
+ for (String k : ht.keySet()) {
+ System.out.println("Cle : "+ k
+ + " Valeur : " + ht.get(k));
+ }
+ for (String v : ht.values()) {
+ System.out.println(" Valeur : " + v);
+ }
+ }
+}
\ No newline at end of file
diff --git a/example-code/HashtableExample.java b/example-code/HashtableExample.java
new file mode 100644
index 0000000..1cb5589
--- /dev/null
+++ b/example-code/HashtableExample.java
@@ -0,0 +1,14 @@
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+public class HashtableExample{
+ public static void main(final String argv[]) {
+ Map ht = new Hashtable();
+ ht.put("Ba", "Bah"); ht.put("Aa", "aha");
+ ht.put("BB", "bebe");
+ for( String k : ht.keySet() ) {
+ System.out.println("Cle : "+ k + " Hash : "+ k.hashCode()
+ + " Valeur : " + ht.get(k));
+ }
+ }
+}
\ No newline at end of file
diff --git a/example-code/InheritExample.java b/example-code/InheritExample.java
new file mode 100644
index 0000000..ffe484d
--- /dev/null
+++ b/example-code/InheritExample.java
@@ -0,0 +1,38 @@
+class Personne {
+ private String nom, prenom, numSecu;
+ public Personne(final String n, final String p, final String ns){
+ nom = n; prenom = p; numSecu = ns;
+ }
+ public String toString(){
+ return "Personne: " + nom + " " + prenom + " " + numSecu;
+ }
+}
+class Enseignant extends Personne {
+ private int nbCours; private String specialite;
+ public Enseignant(final String n, final String p, final String ns,
+ final int nbc, final String specialite) {
+ super(n, p, ns);
+ nbCours = nbc;
+ this.specialite = specialite;
+ }
+ public String toString(){
+ return "Enseignant: " + nbCours + " " +specialite;
+ }
+}
+public class InheritExample {
+ public static void main(final String[] args) {
+ Personne p = new Personne("Dupont","Julien",
+ "1831291...");
+ Enseignant e = new Enseignant("Durand","Emilie",
+ "2780633...",3,"Cloud Computing");
+ System.out.println("p est une Personne "
+ + (p instanceof Personne));
+ System.out.println("p est un Enseignant "
+ + (p instanceof Enseignant));
+
+ System.out.println("e est une Personne "
+ + (e instanceof Personne));
+ System.out.println("e est un Enseignant "
+ + (e instanceof Enseignant));
+ }
+}
diff --git a/example-code/InitPersonne.java b/example-code/InitPersonne.java
new file mode 100644
index 0000000..606d5b7
--- /dev/null
+++ b/example-code/InitPersonne.java
@@ -0,0 +1,8 @@
+import studs.Personne;
+public class InitPersonne {
+ public static void main(final String[] args) {
+ Personne j; // reference
+ j = new Personne("Dupont", "Julien"); // instance creation
+ System.out.println(j);
+ }
+}
diff --git a/example-code/InitScrutin.java b/example-code/InitScrutin.java
new file mode 100644
index 0000000..8210457
--- /dev/null
+++ b/example-code/InitScrutin.java
@@ -0,0 +1,8 @@
+import studsorg.*;
+public class InitScrutin {
+ public static void main(final String[] args) {
+ Personne p; // reference
+ p = new Personne("Dupont", "Julien"); // instance creation
+ Scrutin bde = p.organiserScrutin("Election bde 2010");
+ }
+}
\ No newline at end of file
diff --git a/example-code/IntExample.java b/example-code/IntExample.java
new file mode 100644
index 0000000..defdc62
--- /dev/null
+++ b/example-code/IntExample.java
@@ -0,0 +1,11 @@
+public class IntExample{
+ public static void main(final String argv[]) {
+ Integer i = new Integer("4567");
+ int j = i.intValue();
+ i = 4567; // boxing i = new Integer(4567);
+ j = i / 2 ; // unboxing i.intValue()
+ System.out.println("Integer i :" + i + " int j :" + j + "\n");
+ j = Integer.parseInt("123");
+ System.out.println(" j :" + j + "\n");
+ }
+}
\ No newline at end of file
diff --git a/example-code/LambdaExample.java b/example-code/LambdaExample.java
deleted file mode 100644
index 8416b44..0000000
--- a/example-code/LambdaExample.java
+++ /dev/null
@@ -1,22 +0,0 @@
-import java.util.function.*;
-
-public class LambdaExample {
- // note: this only works in Java 8
-
- static Function inc(int x) {
- return y -> x+y;
- }
-
- static Function mul(int x) {
- return y -> x*y;
- }
-
- public static void main(String[] args) {
- // bad style, generic erasure to get array
- Function[] fs = {inc(5), inc(10), mul(7), mul(2)};
-
- for (Function f : fs)
- System.out.println(
- ((Function)f).apply(100));
- }
-}
\ No newline at end of file
diff --git a/example-code/MoveExample.java b/example-code/MoveExample.java
new file mode 100644
index 0000000..61ff1d2
--- /dev/null
+++ b/example-code/MoveExample.java
@@ -0,0 +1,8 @@
+import shapes.*;
+public class MoveExample{
+ public static void main(final String[] arg) {
+ Movable [] moves = {
+ new PolygoneMove()
+ };
+ }
+}
\ No newline at end of file
diff --git a/example-code/Forest.java b/example-code/Node.java
similarity index 100%
rename from example-code/Forest.java
rename to example-code/Node.java
diff --git a/example-code/Postfix.java b/example-code/Postfix.java
index b9868c3..1f6bdfd 100644
--- a/example-code/Postfix.java
+++ b/example-code/Postfix.java
@@ -1,7 +1,9 @@
+import java.util.Stack;
+
public class Postfix {
// example of using a stack
public static void main(String[] args) {
- Stack stacky = new Stack<>();
+ Stack stacky = new Stack();
for (char ch : "123+45*6-+-".toCharArray()) {
if (ch == '+')
stacky.push(stacky.pop() + stacky.pop());
diff --git a/example-code/ProtExample.java b/example-code/ProtExample.java
new file mode 100644
index 0000000..bd83072
--- /dev/null
+++ b/example-code/ProtExample.java
@@ -0,0 +1,10 @@
+import personnes.*;
+public class ProtExample {
+ public static void main(final String[] args) {
+ PersonneCount p = new PersonneCount("Dupont","Julien", "1831291...");
+ EnseignantCount e = new EnseignantCount("Durand","Emilie",
+ "2780633...",3,"Cloud Computing");
+ System.out.println( p);
+ System.out.println(e);
+ }
+}
\ No newline at end of file
diff --git a/example-code/StackQueue.java b/example-code/StackQueue.java
index 1c7bb84..8ccdb33 100644
--- a/example-code/StackQueue.java
+++ b/example-code/StackQueue.java
@@ -1,13 +1,17 @@
+import java.util.ArrayDeque;
+import java.util.Queue;
+import java.util.Stack;
+
public class StackQueue {
public static void main(String[] args) {
- Stack stack = new Stack<>();
- Queue queue = new Queue<>();
+ Stack stack = new Stack();
+ Queue queue = new ArrayDeque();
stack.push("stack-first");
stack.push("stack-last");
- queue.enqueue("queue-first");
- queue.enqueue("queue-last");
+ queue.add("queue-first");
+ queue.add("queue-last");
for (String s : stack)
System.out.println("stack contains " + s);
@@ -17,6 +21,6 @@ public static void main(String[] args) {
while (!stack.isEmpty())
System.out.println(stack.pop());
while (!queue.isEmpty())
- System.out.println(queue.dequeue());
+ System.out.println(queue.remove());
}
}
\ No newline at end of file
diff --git a/example-code/StdIn.java b/example-code/StdIn.java
deleted file mode 100644
index 09757c3..0000000
--- a/example-code/StdIn.java
+++ /dev/null
@@ -1,12 +0,0 @@
-public class StdInDemo {
- public static void main(String[] args) {
- StdOut.println("int: " + StdIn.readInt());
- StdOut.println("double: " + StdIn.readDouble());
- StdOut.println("String (token): " + StdIn.readString());
- StdOut.println("char: " + StdIn.readChar());
- StdOut.println("char: " + StdIn.readChar());
- StdOut.println("line: " + StdIn.readLine());
- StdOut.println("empty?: " + StdIn.isEmpty());
- }
-}
-/*viz_options {"stdin":"13 3.4 mytoken chars rest of line\nanother line"} */
\ No newline at end of file
diff --git a/example-code/StringEquals.java b/example-code/StringEquals.java
new file mode 100644
index 0000000..e046163
--- /dev/null
+++ b/example-code/StringEquals.java
@@ -0,0 +1,22 @@
+public class StringEquals{
+ public static void main(final String argv[]) {
+ String s = "Java", j = "Java";
+ String m = "Ja";
+ m += "va";
+ if (s == j) {
+ System.out.println("s == j Vrai");
+ } else {
+ System.out.println("s == j Faux");
+ }
+ if (j == m) {
+ System.out.println("j == m Vrai");
+ } else {
+ System.out.println("j == m Faux");
+ }
+ if (j.equals(m)) {
+ System.out.println("j.equals(m) Vrai");
+ } else {
+ System.out.println("j.equals(m) Faux");
+ }
+ }
+}
diff --git a/example-code/StringExample.java b/example-code/StringExample.java
new file mode 100644
index 0000000..b6e2f52
--- /dev/null
+++ b/example-code/StringExample.java
@@ -0,0 +1,14 @@
+import java.util.Date;
+public class StringExample{
+ public static void main(final String argv[]) {
+ String s = "\u00catre ou ne pas \u00eatre";
+ int lg = s.length();
+ System.out.println(s + " " + lg);
+ System.out.println( "Java".substring(2,3));
+ System.out.println( "Java" + "Soft");
+ char[] data = { 'J', 'a', 'v', 'a' };
+ String n = new String(data); System.out.println(n);
+ String p = String.valueOf(Math.PI); System.out.println(p);
+ String d = String.valueOf(new Date()); System.out.println(d);
+ }
+}
\ No newline at end of file
diff --git a/example-code/StringHashTest.java b/example-code/StringHashTest.java
new file mode 100644
index 0000000..2a7112d
--- /dev/null
+++ b/example-code/StringHashTest.java
@@ -0,0 +1,9 @@
+public class StringHashTest {
+ public static void main(String[] args) {
+ String s = "a";
+ for(int i = 0; i< 128; i++){
+ System.out.println(s + " " + s.hashCode());
+ s += "a";
+ }
+ }
+}
\ No newline at end of file
diff --git a/example-code/SymbolTable.java b/example-code/SymbolTable.java
deleted file mode 100644
index 605916f..0000000
--- a/example-code/SymbolTable.java
+++ /dev/null
@@ -1,12 +0,0 @@
-public class SymbolTable {
- public static void main(String[] args) {
- ST st = new ST<>();
- st.put("key1", "value1");
- st.put("key2", "value2");
- st.put("key3", "value3");
- st.put("key1", "different value");
- st.delete("key2");
- for (String s : st.keys())
- StdOut.println(s + " " + st.get(s));
- }
-}
\ No newline at end of file
diff --git a/example-code/TestAssert.java b/example-code/TestAssert.java
new file mode 100644
index 0000000..325d40a
--- /dev/null
+++ b/example-code/TestAssert.java
@@ -0,0 +1,12 @@
+public class TestAssert{
+ // Utilisation de assert dans une classe
+ static double testPos(final double val) throws AssertionError {
+ assert(val > 0.0);
+ return val;
+ }
+ public static void main(final String [] argv) {
+ testPos(10.0);
+ testPos(0.0);
+ testPos(-10.0);
+ }
+}
\ No newline at end of file
diff --git a/example-code/TestClone.java b/example-code/TestClone.java
new file mode 100644
index 0000000..315f872
--- /dev/null
+++ b/example-code/TestClone.java
@@ -0,0 +1,36 @@
+import java.util.ArrayList;
+
+import studsclone.*;
+public class TestClone {
+ public static void main(final String[] args)
+ throws CloneNotSupportedException {
+ Personne p = new Personne("Dupont", "Julien");
+ p.organiserScrutin("Election bde 2010");
+ Personne p1 = p.clone();
+ if (p1 == p) {
+ System.out.println("p == p1");
+ }
+ if (p.getNom() == p1.getNom()) {
+ System.out.println("p et p1 noms ==");
+ }
+ if (p.getPrenom() == p1.getPrenom()) {
+ System.out.println("p et p1 prenoms ==");
+ }
+ ArrayList a1, a2;
+ a1 = p.getScrutins();
+ a2 = p1.getScrutins();
+ if (a1 == a2) {
+ System.out.println("p et p1 scrutins ==");
+ } else {
+ for(int i = 0; i < a1.size(); i++) {
+ if(a1.get(i) == a2.get(i)) {
+ System.out.println("Scrutins de rang " + i +" ==");
+ } else {
+ if(a1.get(i).getOrganisateur() == a2.get(i).getOrganisateur()) {
+ System.out.println("Oraganisateur des scrutins de rang" + i +"==");
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/example-code/TestCloneDeep.java b/example-code/TestCloneDeep.java
new file mode 100644
index 0000000..e080391
--- /dev/null
+++ b/example-code/TestCloneDeep.java
@@ -0,0 +1,37 @@
+import java.util.ArrayList;
+
+import studsclonedeep.Scrutin;
+import studsclonedeep.Personne;
+public class TestCloneDeep {
+ public static void main(final String[] args)
+ throws CloneNotSupportedException {
+ Personne p = new Personne("Dupont", "Julien");
+ p.organiserScrutin("Election bde");
+ Personne p1 = p.clone();
+ if (p1 == p) {
+ System.out.println("p == p1");
+ }
+ if (p.getNom() == p1.getNom()) {
+ System.out.println("p et p1 noms ==");
+ }
+ if (p.getPrenom() == p1.getPrenom()) {
+ System.out.println("p et p1 prenoms ==");
+ }
+ ArrayList a1, a2;
+ a1 = p.getScrutins();
+ a2 = p1.getScrutins();
+ if (a1 == a2) {
+ System.out.println("p et p1 scrutins ==");
+ } else {
+ for(int i = 0; i < a1.size(); i++) {
+ if(a1.get(i) == a2.get(i)) {
+ System.out.println("Scrutins de rang " + i +" ==");
+ } else {
+ if(a1.get(i).getOrganisateur() == a2.get(i).getOrganisateur()) {
+ System.out.println("Oraganisateur des scrutins de rang" + i +"==");
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/example-code/TestCloneLight.java b/example-code/TestCloneLight.java
new file mode 100644
index 0000000..59ccfa6
--- /dev/null
+++ b/example-code/TestCloneLight.java
@@ -0,0 +1,32 @@
+import java.util.ArrayList;
+import studsclonelight.Scrutin;
+import studsclonelight.Personne;
+public class TestCloneLight {
+ public static void main(final String[] args)
+ throws CloneNotSupportedException {
+ Personne p = new Personne("Dupont", "Julien");
+ p.organiserScrutin("Election bde");
+ Personne p1 = p.clone();
+ if (p1 == p) {
+ System.out.println("p == p1");
+ }
+ if (p.getNom() == p1.getNom()) {
+ System.out.println("p et p1 noms ==");
+ }
+ if (p.getPrenom() == p1.getPrenom()) {
+ System.out.println("p et p1 prenoms ==");
+ }
+ ArrayList a1, a2;
+ a1 = p.getScrutins();
+ a2 = p1.getScrutins();
+ if (a1 == a2) {
+ System.out.println("p et p1 scrutins ==");
+ } else {
+ for(int i = 0; i < a1.size(); i++){
+ if(a1.get(i) == a2.get(i)){
+ System.out.println("Scrutin de rang " + i +" ==");
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/example-code/TestExcept.java b/example-code/TestExcept.java
new file mode 100644
index 0000000..5fad1ae
--- /dev/null
+++ b/example-code/TestExcept.java
@@ -0,0 +1,67 @@
+import exceptions.NullException;
+import exceptions.NumException;
+
+public class TestExcept{
+ /**
+ * Methode verifiant qu'une valeur est positive.
+ * @param val valeur a tester
+ * @return valeur d'entree
+ * @throws NumException si valeur negative
+ * @throws NullException si valeur egale a zero.
+ */
+ private static double positifOuNull(final double val)
+ throws NumException, NullException {
+ if (val < 0.0) {
+ throw new NumException(val, "PositifOuNull valeur positive attendue.");
+ }
+ if(val == 0.0) {
+ throw new NullException();
+ }
+ return val;
+ }
+ /**
+ * traitement partiel d'exception les exceptions
+ * NullException sont traitees, les exceptions NumException
+ * sont traitees partiellement et relayees.
+ * @param val valeur a tester
+ * @throws NumException
+ */
+ private static void testPositifOuNull(final double val)
+ throws NumException {
+ double d=0;
+ System.out.println("Dans testPositifOuNull val = "+val);
+ try {
+ d = positifOuNull(val);
+ System.out.println("Pas d'exception le code continue en sequence");
+ }
+ catch (NullException m) {
+ System.out.println("Catch NullException dans testPositifOuNull " + m);
+ return;
+ }
+ catch (NumException m) {
+ System.out.println("Catch NumException dans testPositifOuNull "
+ + "traitement partiel et relais" + m);
+ throw m;
+ }
+ finally {
+ System.out.println("Dans le finally de testPositifOuNull " + d);
+ }
+ }
+ public static void main(final String [] args) {
+ int j = 0;
+
+ for (String oneArg : args){
+ try {
+ j = Integer.parseInt(oneArg);
+ testPositifOuNull(j);
+ }
+ catch (NumberFormatException nfe){
+ System.out.println("Parameter " + oneArg
+ + " should be an integer");
+ }
+ catch(NumException n){
+ System.out.println("Catch dans le main " + n);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/example-code/TestExceptInHerit.java b/example-code/TestExceptInHerit.java
new file mode 100644
index 0000000..bfe2879
--- /dev/null
+++ b/example-code/TestExceptInHerit.java
@@ -0,0 +1,73 @@
+class NumException extends Exception {
+ private static final long serialVersionUID = 1L;
+ public NumException(final double valeur, final String s) {
+ super(s + " valeur : " + valeur);
+ }
+}
+
+class NullException extends NumException {
+ private static final long serialVersionUID = 1L;
+ public NullException() {
+ super(0,"Valeur nulle non attendue");
+ }
+}
+
+public class TestExceptInHerit{
+ /**
+ * Methode verifiant qu'une valeur est positive.
+ * @param val valeur a tester
+ * @return valeur d'entree
+ * @throws NumException si valeur negative
+ * @throws NullException si valeur egale a zero.
+ */
+ private static double positifOuNull(final double val)
+ throws NumException, NullException {
+ if (val < 0.0) {
+ throw new NumException(val, "PositifOuNull valeur positive attendue.");
+ }
+ if(val == 0.0) {
+ throw new NullException();
+ }
+ return val;
+ }
+ /**
+ * traitement partiel d'exception les exceptions
+ * NullException sont traitees, les exceptions NumException
+ * sont traitees partiellement et relayees.
+ * @param val valeur a tester
+ * @throws NumException
+ */
+ private static void testPositifOuNull(final double val)
+ throws NumException {
+ double d=0;
+ System.out.println("Dans testPositifOuNull val = "+val);
+ try {
+ d = positifOuNull(val);
+ System.out.println("Pas d'exception le code continue en sequence");
+ } catch (NullException m) {
+ System.out.println("Catch NullException dans testPositifOuNull " + m);
+ throw m;
+ } catch (NumException m) {
+ System.out.println("Catch NumException dans testPositifOuNull "
+ + "traitement partiel et relais" + m);
+ throw m;
+ }
+ finally {
+ System.out.println("Dans le finally de testPositifOuNull " + d);
+ }
+ }
+ public static void main(final String [] args) {
+ int j = 0;
+ for (String oneArg : args){
+ try {
+ j = Integer.parseInt(oneArg);
+ testPositifOuNull(j);
+ } catch (NumberFormatException nfe){
+ System.out.println("Parameter " + oneArg
+ + " should be an integer");
+ } catch(NumException n){
+ System.out.println("Catch dans le main " + n);
+ }
+ }
+ }
+}
diff --git a/example-code/Exception.java b/example-code/TestException.java
similarity index 91%
rename from example-code/Exception.java
rename to example-code/TestException.java
index b746c1f..797683d 100644
--- a/example-code/Exception.java
+++ b/example-code/TestException.java
@@ -1,4 +1,4 @@
-public class Exception {
+public class TestException {
public static void main(String[] args) {
// this one will be caught
int x = 0;
@@ -14,4 +14,4 @@ public static void main(String[] args) {
System.out.println(1/0);
System.out.println("this won't run");
}
-}
\ No newline at end of file
+}
diff --git a/example-code/TestIter.java b/example-code/TestIter.java
new file mode 100644
index 0000000..98787b2
--- /dev/null
+++ b/example-code/TestIter.java
@@ -0,0 +1,41 @@
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+class Int {
+ int val;
+ Int(int n) { val = n; }
+ int plusPlus() { return val++; }
+ int getVal() {return val; }
+}
+public class TestIter {
+ static void display(List v) {
+ Iterator e = v.iterator();
+ Int s;
+ while(e.hasNext()){
+ s = e.next();
+ System.out.println(" "+ s.getVal());
+ }
+ }
+ static void incrementI(List v){
+ for(Int s : v){
+ s.plusPlus();
+ }
+ }
+ public static void main(String argv[]) {
+ List n = new Vector();
+ for(int i = 0; i < 10 ; i++) {
+ n.add(new Int(i));
+ }
+ Iterator e = n.iterator();
+ Int s;
+ while (e.hasNext()) {
+ s = e.next();
+ s.plusPlus();
+ }
+ System.out.println("Apres initialisation:");
+ display(n);
+ incrementI(n);
+ System.out.println("Apres increment par iterateur:");
+ display(n);
+ }
+}
\ No newline at end of file
diff --git a/example-code/TestPolyMorph.java b/example-code/TestPolyMorph.java
new file mode 100644
index 0000000..d912deb
--- /dev/null
+++ b/example-code/TestPolyMorph.java
@@ -0,0 +1,14 @@
+import personnes.Personne;
+import personnes.Enseignant;
+public class TestPolyMorph {
+ public static void main(final String[] args) {
+ Personne p = new Personne("Dupont","Julien",
+ "1831291...");
+ Enseignant e = new Enseignant("Durand","Emilie",
+ "2780633...",3,"Cloud Computing");
+ System.out.println(p.toString());
+ System.out.println(e.toString());
+ p = e; // UpCast
+ System.out.println(p.toString());
+ }
+}
\ No newline at end of file
diff --git a/example-code/TestSimpleExcept.java b/example-code/TestSimpleExcept.java
new file mode 100644
index 0000000..b1f3302
--- /dev/null
+++ b/example-code/TestSimpleExcept.java
@@ -0,0 +1,41 @@
+import exceptions.NumException;
+
+public class TestSimpleExcept {
+ /**
+ * Positif teste si la valeur du parametre val est positive.
+ * @param val valeur a tester
+ * @throws NumException si val est < 0
+ */
+ private static void positif(final double val) throws NumException {
+ if (val < 0.0) throw new NumException(val, "Valeur positive attendue.");
+ return;
+ }
+ /**
+ * testPositif utilise positif et relaye l'exception NumException.
+ * @param val valeur a tester.
+ * @throws NumException lorsque positif emet NumException
+ */
+ private static void testPositif(double val) throws NumException {
+ positif(val);
+ System.out.println("Pas d'exception le code continue en sequence");
+ return ;
+ }
+ /**
+ * Traitement des arguments de main par test des
+ * valeurs entieres positives.
+ * @param argv arguments de la ligne de commande.
+ */
+ public static void main(final String [] argv) {
+ int i, j = 0;
+ for (i=0;i v = new Vector();
+ v.addElement("John");
+ v.addElement("Georges");
+ for(int i=0;i v=new Vector();
+ v.add("un"); v.add("deux"); v.add(2, "trois");
+ System.out.println("Contenu du vecteur :");
+ for (int i=0; i v = new Vector();
+ v.add("John"); v.add("Georges");
+ System.out.println("Taille de la liste " + v.size());
+ for(String s : v){
+ System.out.println(" "+s);
+ }
+ }
+}
\ No newline at end of file
diff --git a/example-code/VectorIterator.java b/example-code/VectorIterator.java
new file mode 100644
index 0000000..94ca57b
--- /dev/null
+++ b/example-code/VectorIterator.java
@@ -0,0 +1,17 @@
+import java.util.Vector;
+import java.util.List;
+import java.util.Iterator;
+public class VectorIterator {
+ public static void main(String argv[]) {
+ List v = new Vector();
+ v.add("John"); v.add("Georges");
+ Iterator e = v.iterator();
+ while(e.hasNext()){
+ System.out.println(" " + e.next());
+ }
+ // Parcours avec une boucle for
+ for(e = v.iterator();e.hasNext();){
+ System.out.println(" " + e.next());
+ }
+ }
+}
\ No newline at end of file
diff --git a/example-code/VectorListExample.java b/example-code/VectorListExample.java
new file mode 100644
index 0000000..5653a7e
--- /dev/null
+++ b/example-code/VectorListExample.java
@@ -0,0 +1,15 @@
+import java.util.List;
+import java.util.Vector;
+public class VectorListExample{
+ public static void main(String argv[]) {
+ String nom = "John";
+ List v = new Vector();
+ for (int i=0;i<5;i++) {
+ v.add(nom);
+ }
+
+ for (String s : v) {
+ System.out.println("s : " + s);
+ }
+ }
+}
\ No newline at end of file
diff --git a/example-code/complements/TestEquals.java b/example-code/complements/TestEquals.java
new file mode 100644
index 0000000..3266884
--- /dev/null
+++ b/example-code/complements/TestEquals.java
@@ -0,0 +1,28 @@
+package complements;
+import complements.equalshash.*;
+import java.util.List;
+import java.util.ArrayList;
+class TestEquals {
+ public static int sumEven() {
+ List li = new ArrayList();
+ for (int i = 1; i < 50; i += 2)
+ li.add(i);
+ int sum = 0;
+ for (Integer i: li)
+ if (i % 2 == 0)
+ sum += i;
+ return sum;
+}
+ public static void main(String[] args) {
+ Personne mickey = new Personne("Mickey","Mouse","1459066503202");
+ Personne donald = new Personne("Donald","Duc", "1459066503203");
+
+ if(mickey.equals(donald)){
+ System.out.println("Il y a un probleme");
+ } else {
+ System.out.println(mickey + " et "+ donald+" ne sont pas identiques");
+ }
+
+ }
+
+}
diff --git a/example-code/complements/TestToString.java b/example-code/complements/TestToString.java
new file mode 100644
index 0000000..e21da08
--- /dev/null
+++ b/example-code/complements/TestToString.java
@@ -0,0 +1,14 @@
+package complements;
+
+import complements.equalshash.*;
+
+public class TestToString {
+ public static void main(String[] args) {
+ Personne mickey = new Personne("Mickey","Mouse","1459066503202");
+ Enseignant walt = new Enseignant("Donald","Duc", "1459066503203",1,"cartoon");
+
+ System.out.println(mickey);
+ System.out.println(walt);
+
+ }
+}
diff --git a/example-code/complements/bases/Carre.java b/example-code/complements/bases/Carre.java
new file mode 100644
index 0000000..b65c7a4
--- /dev/null
+++ b/example-code/complements/bases/Carre.java
@@ -0,0 +1,14 @@
+package complements.bases;
+
+public class Carre {
+ private double cx, cy, cote;
+ public double area() { return cote * cote; }
+ public Carre(final double x, final double y, final double r) {
+ cx = x; cy = y; cote = r; }
+ public Carre(final double c) { cx = cy = 0; cote = c; }
+ public Carre(final Carre i) { cx = i.cx; cy=i.cy; cote=i.cote; }
+ public Carre() { this(0.0, 0.0, 0.0); }
+ public String toString(){
+ return "Carre x=" + cx + " y=" + cy + " r=" + cote;
+ }
+}
diff --git a/example-code/complements/bases/CarreMain.java b/example-code/complements/bases/CarreMain.java
new file mode 100644
index 0000000..581374d
--- /dev/null
+++ b/example-code/complements/bases/CarreMain.java
@@ -0,0 +1,15 @@
+package complements.bases;
+
+public class CarreMain {
+ public static void main(final String[] args) {
+ Carre c1 = new Carre(10,10,10);
+ Carre c2 = new Carre(20,20,20);
+ System.out.println(c1.toString());
+ System.out.println(c2);
+ Carre c3 = c1;
+ System.out.println(c3);
+ Carre c4 = new Carre(c2);
+ System.out.println(c4);
+ }
+
+}
diff --git a/example-code/complements/bases/CarrePoint.java b/example-code/complements/bases/CarrePoint.java
new file mode 100644
index 0000000..eac09da
--- /dev/null
+++ b/example-code/complements/bases/CarrePoint.java
@@ -0,0 +1,23 @@
+package complements.bases;
+
+public class CarrePoint {
+ private Point centre;
+ private double cote;
+ public double area() { return cote*cote; }
+ public CarrePoint(final double x, final double y, final double r) {
+ centre = new Point(x, y);
+ cote = r;
+ }
+ public CarrePoint(final double r) {
+ centre = new Point(0,0);
+ cote = r;
+ }
+ public CarrePoint(final CarrePoint i) {
+ centre = new Point(i.centre);
+ cote=i.cote;
+ }
+ public CarrePoint() { this(0.0); }
+ public String toString(){
+ return "CarrePoint :" + centre + " cote=" + cote;
+ }
+}
diff --git a/example-code/complements/bases/CarrePointMain.java b/example-code/complements/bases/CarrePointMain.java
new file mode 100644
index 0000000..a21ae9c
--- /dev/null
+++ b/example-code/complements/bases/CarrePointMain.java
@@ -0,0 +1,14 @@
+package complements.bases;
+
+public class CarrePointMain {
+ public static void main(final String[] args) {
+ CarrePoint c1 = new CarrePoint(10,10,10);
+ CarrePoint c2 = new CarrePoint(20,20,20);
+ System.out.println(c1.toString());
+ System.out.println(c2);
+ CarrePoint c3 = c1;
+ System.out.println(c3);
+ CarrePoint c4 = new CarrePoint(c2);
+ System.out.println(c4);
+ }
+}
diff --git a/example-code/complements/bases/Cercle.java b/example-code/complements/bases/Cercle.java
new file mode 100644
index 0000000..6dca6a5
--- /dev/null
+++ b/example-code/complements/bases/Cercle.java
@@ -0,0 +1,15 @@
+package complements.bases;
+
+class Cercle {
+ public static final double PI = 3.14159;
+ private double cx, cy, cr;
+ public double area() { return PI*cr*cr; }
+ public Cercle(final double x, final double y, final double r) {
+ cx = x; cy = y; cr = r; }
+ public Cercle(final double r) { cx = cy = 0; cr = r; }
+ public Cercle(final Cercle i) { cx = i.cx; cy=i.cy; cr=i.cr; }
+ public Cercle() { this(0.0, 0.0, 0.0); }
+ public String toString(){
+ return "Cercle x=" + cx + " y=" + cy + " r=" + cr;
+ }
+}
diff --git a/example-code/complements/bases/CercleMain.java b/example-code/complements/bases/CercleMain.java
new file mode 100644
index 0000000..a88bc3e
--- /dev/null
+++ b/example-code/complements/bases/CercleMain.java
@@ -0,0 +1,15 @@
+package complements.bases;
+
+
+public class CercleMain {
+ public static void main(final String[] args) {
+ Cercle c1 = new Cercle(10,10,10);
+ Cercle c2 = new Cercle(20,20,20);
+ System.out.println(c1.toString());
+ System.out.println(c2);
+ Cercle c3 = c1;
+ System.out.println(c3);
+ Cercle c4 = new Cercle(c2);
+ System.out.println(c4);
+ }
+}
\ No newline at end of file
diff --git a/example-code/complements/bases/CerclePoint.java b/example-code/complements/bases/CerclePoint.java
new file mode 100644
index 0000000..991f279
--- /dev/null
+++ b/example-code/complements/bases/CerclePoint.java
@@ -0,0 +1,24 @@
+package complements.bases;
+
+public class CerclePoint {
+ public static final double PI = 3.14159;
+ private Point centre;
+ private double cr;
+ public double area() { return PI*cr*cr; }
+ public CerclePoint(final double x, final double y, final double r) {
+ centre = new Point(x, y);
+ cr = r;
+ }
+ public CerclePoint(final double r) {
+ centre = new Point(0,0);
+ cr = r;
+ }
+ public CerclePoint(final CerclePoint i) {
+ centre = new Point(i.centre);
+ cr=i.cr;
+ }
+ public CerclePoint() { this(0.0); }
+ public String toString(){
+ return "CerclePoint :" + centre + " r=" + cr;
+ }
+}
diff --git a/example-code/complements/bases/CerclePointMain.java b/example-code/complements/bases/CerclePointMain.java
new file mode 100644
index 0000000..b51f467
--- /dev/null
+++ b/example-code/complements/bases/CerclePointMain.java
@@ -0,0 +1,14 @@
+package complements.bases;
+
+public class CerclePointMain {
+ public static void main(final String[] args) {
+ CerclePoint c1 = new CerclePoint(10,10,10);
+ CerclePoint c2 = new CerclePoint(20,20,20);
+ System.out.println(c1.toString());
+ System.out.println(c2);
+ CerclePoint c3 = c1;
+ System.out.println(c3);
+ CerclePoint c4 = new CerclePoint(c2);
+ System.out.println(c4);
+ }
+}
diff --git a/example-code/complements/bases/Point.java b/example-code/complements/bases/Point.java
new file mode 100644
index 0000000..61d7d95
--- /dev/null
+++ b/example-code/complements/bases/Point.java
@@ -0,0 +1,12 @@
+package complements.bases;
+
+public class Point {
+ private double cx, cy;
+ public Point(final double x, final double y) {
+ cx = x; cy = y; }
+ public Point(final Point p) {
+ cx = p.cx; cy = p.cy; }
+ public String toString(){
+ return "Point x=" + cx + " y=" + cy ;
+ }
+}
diff --git a/example-code/complements/collections/BadHash.java b/example-code/complements/collections/BadHash.java
new file mode 100644
index 0000000..a07edc4
--- /dev/null
+++ b/example-code/complements/collections/BadHash.java
@@ -0,0 +1,5 @@
+package complements.collections;
+
+public class BadHash {
+
+}
diff --git a/example-code/complements/collections/BadHashExample.java b/example-code/complements/collections/BadHashExample.java
new file mode 100644
index 0000000..025f492
--- /dev/null
+++ b/example-code/complements/collections/BadHashExample.java
@@ -0,0 +1,130 @@
+package complements.collections;
+import java.util.*;
+class X1 {
+ private String a,b;
+ public X1(final String a, final String b) {
+ this.a = a;
+ this.b = b;
+ }
+ @Override
+ public String toString(){
+ return "X a = " +a +" b = "+b;
+ }
+}
+class X2 {
+ private String a,b;
+ public X2(final String a, final String b) {
+ this.a = a;
+ this.b = b;
+ }
+ @Override
+ public String toString(){
+ return "X a = " +a +" b = "+b;
+ }
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (!(obj instanceof X2))
+ return false;
+ X2 other = (X2) obj;
+ if (a == null) {
+ if (other.a != null)
+ return false;
+ } else if (!a.equals(other.a))
+ return false;
+ if (b == null) {
+ if (other.b != null)
+ return false;
+ } else if (!b.equals(other.b))
+ return false;
+ return true;
+ }
+}
+class X3 {
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((a == null) ? 0 : a.hashCode());
+ result = prime * result + ((b == null) ? 0 : b.hashCode());
+ return result;
+ }
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (!(obj instanceof X3))
+ return false;
+ X3 other = (X3) obj;
+ if (a == null) {
+ if (other.a != null)
+ return false;
+ } else if (!a.equals(other.a))
+ return false;
+ if (b == null) {
+ if (other.b != null)
+ return false;
+ } else if (!b.equals(other.b))
+ return false;
+ return true;
+ }
+ private String a,b;
+ public X3(final String a, final String b) {
+ this.a = a;
+ this.b = b;
+ }
+ @Override
+ public String toString(){
+ return "X a = " +a +" b = "+b;
+ }
+}
+
+public class BadHashExample {
+ public static void printHash(Object X){
+ System.out.println("Hash de " + X.toString() +" = " + X.hashCode());
+ }
+ public static void main(String[] args) {
+ X1 x1 = new X1("a","b");
+ X1 y1 = new X1("a","b");
+ Hashtable h1 = new Hashtable();
+ h1.put(x1, "c'est x");
+ printHash(x1);
+ h1.put(y1, "c'est y");
+ printHash(y1);
+ if(x1.equals(y1)){
+ System.out.println("x1 et y1 sont egaux");
+ }
+ System.out.println("nb elements dans h1 = " + h1.size());
+
+ X2 x2 = new X2("a","b");
+ X2 y2 = new X2("a","b");
+ Hashtable h2 = new Hashtable();
+ h2.put(x2, "c'est x2");
+ printHash(x2);
+ printHash(y2);
+
+ h2.put(y2, "c'est y2");
+ if(x2.equals(y2)){
+ System.out.println("x2 et y2 sont egaux");
+ }
+ System.out.println("nb elements dans h2 = " + h2.size());
+
+ X3 x3 = new X3("a","b");
+ X3 y3 = new X3("a","b");
+ Hashtable h3 = new Hashtable();
+ h3.put(x3, "c'est x");
+ h3.put(y3, "c'est y");
+ printHash(x3);
+ printHash(y3);
+ if(x3.equals(y3)){
+ System.out.println("x et y sont egaux");
+ }
+ System.out.println("nb elements dans h3 = " + h3.size());
+ }
+
+}
diff --git a/example-code/complements/collections/RemoveExamples.java b/example-code/complements/collections/RemoveExamples.java
new file mode 100644
index 0000000..45d1590
--- /dev/null
+++ b/example-code/complements/collections/RemoveExamples.java
@@ -0,0 +1,29 @@
+package complements.collections;
+import java.util.*;
+
+import complements.equalshash.*;
+
+public class RemoveExamples {
+
+ /**
+ * @param args
+ */
+ public static void main(final String[] args) {
+ List vPersonnes = new Vector();
+ Personne pi=null;
+ for(int i = 0; i< 10; i++){
+ vPersonnes.add(new Personne("Dupont"+i, "Jules","19102271271"+i));
+ }
+ for(Personne p : vPersonnes){
+ System.out.println(p);
+ }
+ Iterator it ;
+ for(it= vPersonnes.iterator();it.hasNext();pi=it.next()){
+ if(pi.equals(new Personne("Dupont"+5, "Jules","19102271271"+5))){
+ it.remove();
+ }
+ }
+
+ }
+
+}
diff --git a/example-code/complements/commeenc/Bissextile.java b/example-code/complements/commeenc/Bissextile.java
new file mode 100644
index 0000000..c7fb2ab
--- /dev/null
+++ b/example-code/complements/commeenc/Bissextile.java
@@ -0,0 +1,26 @@
+package complements.commeenc;
+
+public class Bissextile {
+
+ private static boolean estbissextile(final int an){
+ if (an%400 ==0) { return true; }
+ if (an%100 == 0) { return false; }
+ if (an%4 != 0) { return false; }
+ return true;
+ }
+ public static void main(final String[] args) {
+ int annee = Console.readInt("Tapez une année > 1582 :");
+ System.out.println("L'année " + annee + " est-elle bissextile?");
+ if (annee <1582) {
+ System.out.println("Les années <1582 ne sont pas valides");
+ System.exit(0);
+ }
+ System.out.print("L'année " + annee );
+ if (estbissextile(annee)) {
+ System.out.println(" est bissextile");
+ } else {
+ System.out.println(" n'est pas bissextile");
+ }
+ }
+
+}
diff --git a/example-code/complements/commeenc/Console.java b/example-code/complements/commeenc/Console.java
new file mode 100755
index 0000000..6edd8ec
--- /dev/null
+++ b/example-code/complements/commeenc/Console.java
@@ -0,0 +1,68 @@
+package complements.commeenc;
+import java.io.*;
+/**
+ * Permet de lire des nombres et des chaines de caracteres
+ * au clavier.
+ */
+public class Console {
+ /**
+ * La console est un flot de caracteres bufferise.
+ */
+ private static BufferedReader console =
+ new BufferedReader(new InputStreamReader(System.in));
+ /**
+ * Affiche un message a l'ecran sans fin de ligne.
+ * @param prompt Message a afficher
+ */
+ public static void printPrompt(final String prompt) {
+ System.out.print(prompt + " ");
+ System.out.flush();
+ }
+ /**
+ * Lecture d'une chaine de caracteres au clavier. La chaine ne
+ * contient pas le caractere 'fin de ligne'. En cas de fin de
+ * fichier ou d'erreur, la chaine retournee vaut null.
+ * @return La chaine lue
+ */
+ public static String readLine() {
+ String r = "";
+ try {
+ r = console.readLine();
+ } catch(IOException e) { r = null; }
+ return r;
+ }
+ /**
+ * Lecture d'une chaine de caracteres au clavier avec affichage d'un
+ * prompt.
+ * @param prompt Message a afficher
+ * @return La chaine lue
+ * @see #printPrompt(String)
+ * @see #readLine()
+ */
+ public static String readLine(final String prompt) {
+ printPrompt(prompt);
+ return readLine();
+ }
+ /**
+ * Lecture d'un entier au clavier.
+ * @param prompt Message a afficher
+ * @return L'entier lu
+ * @exception NumberFormatException en cas d'erreur
+ */
+ public static int readInt(final String prompt)
+ throws NumberFormatException {
+ printPrompt(prompt);
+ return Integer.valueOf(readLine().trim()).intValue();
+ }
+ /**
+ * Lecture d'un double au clavier.
+ * @param prompt Message a afficher
+ * @return Le double lu
+ * @exception NumberFormatException en cas d'erreur
+ */
+ public static double readDouble(final String prompt)
+ throws NumberFormatException {
+ printPrompt(prompt);
+ return Double.valueOf(readLine().trim()).doubleValue();
+ }
+}
\ No newline at end of file
diff --git a/example-code/complements/commeenc/Premier.java b/example-code/complements/commeenc/Premier.java
new file mode 100644
index 0000000..24b3ebf
--- /dev/null
+++ b/example-code/complements/commeenc/Premier.java
@@ -0,0 +1,22 @@
+package complements.commeenc;
+public class Premier {
+ private static boolean estPremier(final int nb) {
+ if (nb == 1) { return false; }
+ for (int i=2; i<= nb/2; i++) {
+ if (nb%i == 0) {
+ return false;
+ }
+ }
+ return true;
+ }
+ public static void main(String[] args) {
+ int nombre = Console.readInt("Entrez un nombre entier");
+ System.out.println("Le nombre " + nombre + " est-il premier ?");
+ System.out.print("Le nombre " + nombre);
+ if (estPremier(nombre)) {
+ System.out.println(" est premier");
+ } else {
+ System.out.println(" n'est pas premier");
+ }
+ }
+}
\ No newline at end of file
diff --git a/example-code/complements/commeenc/TousLesPremiers.java b/example-code/complements/commeenc/TousLesPremiers.java
new file mode 100644
index 0000000..214de50
--- /dev/null
+++ b/example-code/complements/commeenc/TousLesPremiers.java
@@ -0,0 +1,27 @@
+package complements.commeenc;
+
+public class TousLesPremiers {
+ private static final boolean debug = false;
+ private static boolean estPremier(final int nb){
+ if (nb == 1) { return false; }
+ if (nb%2 == 0) { return false; }
+ for (int i=3; i<= nb/i; i++) {
+ if (nb%i == 0) {
+ if (debug) {
+ System.out.println(i + " est un diviseur de " + nb + "\n");
+ }
+ return false; }
+ }
+ return true;
+ }
+ public static void main(String[] args) {
+ int nombre = Console.readInt("Entrez un nombre entier");
+ System.out.println("Quels sont les nombres premiers inferieurs à : " + nombre);
+ for (int j=2; j possibles;
+ public AbsScrutin(final String nom, final Personne organisateur){
+ nomScrutin = nom;
+ this.organisateur = organisateur;
+ possibles = new Vector();
+ }
+ public Personne getOrganisateur() {
+ return organisateur;
+ }
+ public String getNomScrutin() {
+ return nomScrutin;
+ }
+}
\ No newline at end of file
diff --git a/example-code/complements/studtests/Bulletin.java b/example-code/complements/studtests/Bulletin.java
new file mode 100644
index 0000000..7a33add
--- /dev/null
+++ b/example-code/complements/studtests/Bulletin.java
@@ -0,0 +1,21 @@
+package complements.studtests;
+import java.util.List;
+import java.util.Vector;
+
+public class Bulletin{
+ Personne p;
+ AbsScrutin s;
+ List lesChoix;
+ public Bulletin(Personne votant, AbsScrutin scrutin){
+ p = votant;
+ s = scrutin;
+ lesChoix = new Vector();
+ }
+ @SuppressWarnings("unchecked")
+ public List getChoix(){
+ Vector toClone = (Vector) lesChoix;
+ Vector cloned = (Vector) toClone.clone();
+ return cloned;
+ }
+
+}
\ No newline at end of file
diff --git a/example-code/complements/studtests/Choix.java b/example-code/complements/studtests/Choix.java
new file mode 100644
index 0000000..ac90310
--- /dev/null
+++ b/example-code/complements/studtests/Choix.java
@@ -0,0 +1,14 @@
+package complements.studtests;
+import java.util.List;
+import java.util.Vector;
+
+public abstract class Choix {
+ private List lesBulletins;
+ public Choix(){
+ lesBulletins = new Vector();
+ }
+ protected int addBulletin(Bulletin b){
+ lesBulletins.add(b);
+ return lesBulletins.size();
+ }
+}
diff --git a/example-code/complements/studtests/Personne.java b/example-code/complements/studtests/Personne.java
new file mode 100644
index 0000000..e8505ee
--- /dev/null
+++ b/example-code/complements/studtests/Personne.java
@@ -0,0 +1,15 @@
+package complements.studtests;
+public class Personne {
+ String nom, prenom;
+ int nbParticipations = 0, nbOrganisations = 0;
+
+ public Personne(final String nom, final String prenom) {
+ this.nom = nom; this.prenom = prenom;
+ }
+ void voter(final Bulletin b) {
+ }
+ void consulterResultat(final AbsScrutin s) {
+ }
+ void seRetirerDUnScrutin(final AbsScrutin s) {
+ }
+}
\ No newline at end of file
diff --git a/example-code/complements/studtests/PlageHoraire.java b/example-code/complements/studtests/PlageHoraire.java
new file mode 100644
index 0000000..0f46b9d
--- /dev/null
+++ b/example-code/complements/studtests/PlageHoraire.java
@@ -0,0 +1,20 @@
+package complements.studtests;
+import java.util.Date;
+
+public class PlageHoraire extends Choix {
+ private Date dateDebut, dateFin;
+ public PlageHoraire(final Date debut, final Date fin) {
+ super();
+ dateDebut = debut;
+ dateFin = fin;
+ }
+ public Date getDateDebut() {
+ return dateDebut;
+ }
+ public Date getDateFin() {
+ return dateFin;
+ }
+ public int addBulletin(final Bulletin b){
+ return super.addBulletin(b);
+ }
+}
diff --git a/example-code/complements/studtests/ScrutinChoix.java b/example-code/complements/studtests/ScrutinChoix.java
new file mode 100644
index 0000000..7ef075f
--- /dev/null
+++ b/example-code/complements/studtests/ScrutinChoix.java
@@ -0,0 +1,19 @@
+package complements.studtests;
+
+import java.util.List;
+import java.util.Vector;
+
+public class ScrutinChoix extends AbsScrutin {
+ private List choix;
+ public ScrutinChoix(final String nom, final Personne organisateur) {
+ super(nom, organisateur);
+ choix = new Vector();
+ }
+ public int addChoix(final Choix c) {
+ choix.add(c);
+ return choix.size();
+ }
+ public int getSize() {
+ return choix.size();
+ }
+}
diff --git a/example-code/complements/studtests/ScrutinPlagesHoraires.java b/example-code/complements/studtests/ScrutinPlagesHoraires.java
new file mode 100644
index 0000000..4eabb1a
--- /dev/null
+++ b/example-code/complements/studtests/ScrutinPlagesHoraires.java
@@ -0,0 +1,14 @@
+package complements.studtests;
+import java.util.Vector;
+
+public class ScrutinPlagesHoraires extends AbsScrutin {
+ private Vector plages;
+ public ScrutinPlagesHoraires(final String nom, final Personne organisateur) {
+ super(nom, organisateur);
+ plages = new Vector();
+ }
+ public int addPlage(final PlageHoraire p) {
+ plages.add(p);
+ return plages.size();
+ }
+}
\ No newline at end of file
diff --git a/example-code/complements/studtests/Studs.java b/example-code/complements/studtests/Studs.java
new file mode 100644
index 0000000..64b9963
--- /dev/null
+++ b/example-code/complements/studtests/Studs.java
@@ -0,0 +1,16 @@
+package complements.studtests;
+import java.util.List;
+import java.util.Vector;
+
+public class Studs {
+ private List lesChoix;
+ private List lesScrutins;
+ private List lesBulletins;
+ private List lesParticipants;
+ public Studs(){
+ lesChoix = new Vector();
+ lesScrutins = new Vector();
+ lesBulletins = new Vector();
+ lesParticipants = new Vector();
+ }
+}
\ No newline at end of file
diff --git a/example-code/exceptions/NullException.java b/example-code/exceptions/NullException.java
new file mode 100644
index 0000000..d00f0cd
--- /dev/null
+++ b/example-code/exceptions/NullException.java
@@ -0,0 +1,8 @@
+package exceptions;
+
+public class NullException extends NumException {
+ private static final long serialVersionUID = 1L;
+ public NullException() {
+ super(0,"Valeur nulle non attendue");
+ }
+}
\ No newline at end of file
diff --git a/example-code/exceptions/NumException.java b/example-code/exceptions/NumException.java
new file mode 100644
index 0000000..e74b82e
--- /dev/null
+++ b/example-code/exceptions/NumException.java
@@ -0,0 +1,7 @@
+package exceptions;
+public class NumException extends java.lang.Exception {
+ private static final long serialVersionUID = 1L;
+ public NumException(final double valeur, final String s) {
+ super(s + " valeur : " + valeur);
+ }
+}
diff --git a/example-code/personnes/Enseignant.java b/example-code/personnes/Enseignant.java
new file mode 100644
index 0000000..727be8b
--- /dev/null
+++ b/example-code/personnes/Enseignant.java
@@ -0,0 +1,13 @@
+package personnes;
+public class Enseignant extends Personne {
+ private int nbCours; private String specialite;
+ public Enseignant(final String n, final String p, final String ns,
+ final int nbc, final String specialite) {
+ super(n, p, ns);
+ nbCours = nbc;
+ this.specialite = specialite;
+ }
+ public String toString(){
+ return "Enseignant: " + nbCours + " " +specialite;
+ }
+}
\ No newline at end of file
diff --git a/example-code/personnes/EnseignantCount.java b/example-code/personnes/EnseignantCount.java
new file mode 100644
index 0000000..3bdd949
--- /dev/null
+++ b/example-code/personnes/EnseignantCount.java
@@ -0,0 +1,18 @@
+package personnes;
+public class EnseignantCount extends PersonneCount {
+ int nbCours, numens;
+ String specialite;
+ private static int count = 0;
+ public EnseignantCount(final String n, final String p, final String ns,
+ final int nbc, final String specialite) {
+ super(n, p, ns);
+ nbCours = nbc; numens = count++;
+ this.specialite = specialite;
+ }
+
+ @Override
+ public String toString(){
+ return "Enseignant numero " + numens
+ + " personne numero " + numPerson;
+ }
+}
\ No newline at end of file
diff --git a/example-code/personnes/Personne.java b/example-code/personnes/Personne.java
new file mode 100644
index 0000000..0a78edf
--- /dev/null
+++ b/example-code/personnes/Personne.java
@@ -0,0 +1,10 @@
+package personnes;
+public class Personne {
+ private String nom, prenom, numSecu;
+ public Personne(final String n, final String p, final String ns){
+ nom = n; prenom = p; numSecu = ns;
+ }
+ public String toString(){
+ return "Personne: " + nom + " " + prenom + " " + numSecu;
+ }
+}
\ No newline at end of file
diff --git a/example-code/personnes/PersonneCount.java b/example-code/personnes/PersonneCount.java
new file mode 100644
index 0000000..d781592
--- /dev/null
+++ b/example-code/personnes/PersonneCount.java
@@ -0,0 +1,15 @@
+package personnes;
+public class PersonneCount {
+ private String nom, prenom, numSecu;
+ protected int numPerson;
+ static protected int count = 0;
+ public PersonneCount(final String n, final String p, final String ns){
+ nom = n; prenom = p; numSecu = ns;
+ numPerson = count++;
+ }
+
+ @Override
+ public String toString(){
+ return "Personne numero " + numPerson + " parmi " + count;
+ }
+}
\ No newline at end of file
diff --git a/example-code/shapes/Movable.java b/example-code/shapes/Movable.java
new file mode 100644
index 0000000..47490d8
--- /dev/null
+++ b/example-code/shapes/Movable.java
@@ -0,0 +1,8 @@
+package shapes;
+public interface Movable {
+ public Place saPlace();
+ public void avancer();
+ public void reculer();
+ public void monter();
+ public void descendre();
+}
\ No newline at end of file
diff --git a/example-code/shapes/Place.java b/example-code/shapes/Place.java
new file mode 100644
index 0000000..0d1c2bb
--- /dev/null
+++ b/example-code/shapes/Place.java
@@ -0,0 +1,8 @@
+package shapes;
+public class Place implements Movable {
+ public Place saPlace(){return this;}
+ public void avancer(){}
+ public void reculer(){}
+ public void monter(){}
+ public void descendre(){}
+}
\ No newline at end of file
diff --git a/example-code/shapes/PolygoneMove.java b/example-code/shapes/PolygoneMove.java
new file mode 100644
index 0000000..d3e107c
--- /dev/null
+++ b/example-code/shapes/PolygoneMove.java
@@ -0,0 +1,12 @@
+package shapes;
+public class PolygoneMove implements Movable {
+ private Place maPlace;
+ public PolygoneMove() {
+ maPlace = new Place();
+ }
+ public Place saPlace() {return maPlace;}
+ public void avancer() {maPlace.avancer();}
+ public void reculer() {maPlace.reculer();}
+ public void monter() {maPlace.monter();}
+ public void descendre() {maPlace.descendre();}
+}
\ No newline at end of file
diff --git a/example-code/studs/Bulletin.java b/example-code/studs/Bulletin.java
new file mode 100644
index 0000000..33ae837
--- /dev/null
+++ b/example-code/studs/Bulletin.java
@@ -0,0 +1,48 @@
+package studs;
+public class Bulletin{
+ private boolean value;
+ private Personne votant;
+ private Scrutin scrutin;
+ private Choix choix;
+ public Bulletin(final Personne p, final Scrutin s,
+ final Choix c, final boolean v) {
+ votant = p;
+ scrutin = s;
+ value = v;
+ choix = c;
+ choix.addBulletin(this);
+ }
+ public boolean getValue() {
+ return value;
+ }
+ public void setValue(final boolean val) {
+ value = val;
+ }
+ public void retirerDuChoix() {
+ choix.retirerBulletin(this);
+ }
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (!(obj instanceof Bulletin))
+ return false;
+ Bulletin other = (Bulletin) obj;
+ if (choix == null) {
+ if (other.choix != null)
+ return false;
+ } else if (!choix.equals(other.choix))
+ return false;
+ if (scrutin == null) {
+ if (other.scrutin != null)
+ return false;
+ } else if (!scrutin.equals(other.scrutin))
+ return false;
+ if (votant == null) {
+ if (other.votant != null)
+ return false;
+ } else if (!votant.equals(other.votant))
+ return false;
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/example-code/studs/Choix.java b/example-code/studs/Choix.java
new file mode 100644
index 0000000..2154f04
--- /dev/null
+++ b/example-code/studs/Choix.java
@@ -0,0 +1,52 @@
+package studs;
+import java.util.List;
+import java.util.Vector;
+public abstract class Choix {
+ private List lesBulletins;
+ int nbBulletinsPour, nbBulletinsContre;
+ public Choix() {
+ lesBulletins = new Vector();
+ nbBulletinsPour = 0;
+ nbBulletinsContre = 0;
+ }
+ public int addBulletin(Bulletin b) {
+ lesBulletins.add(b);
+ if(b.getValue()){
+ nbBulletinsPour++ ;
+ } else {
+ nbBulletinsContre++ ;
+ }
+ return lesBulletins.size();
+ }
+ public int getNbBulletinsPour() {
+ return nbBulletinsPour;
+ }
+ public int getNbBulletinsContre(){
+ return nbBulletinsContre;
+ }
+ public void retirerBulletin(final Bulletin retrait) {
+ if(lesBulletins.remove(retrait)){
+ if(retrait.getValue()) {
+ nbBulletinsPour-- ;
+ } else {
+ nbBulletinsContre-- ;
+ }
+ }
+ }
+ public void modifierBulletin(final Bulletin changed) {
+ int rang = lesBulletins.indexOf(changed);
+ if (rang >=0) {
+ Bulletin aChanger = lesBulletins.get(rang);
+ if (aChanger.getValue() != changed.getValue()) {
+ aChanger.setValue(changed.getValue());
+ }
+ if (aChanger.getValue()) {
+ nbBulletinsContre-- ;
+ nbBulletinsPour++;
+ } else {
+ nbBulletinsContre++ ;
+ nbBulletinsPour--;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/example-code/studs/Personne.java b/example-code/studs/Personne.java
new file mode 100644
index 0000000..947111b
--- /dev/null
+++ b/example-code/studs/Personne.java
@@ -0,0 +1,11 @@
+package studs;
+public class Personne {
+ private String nom, prenom;
+ private int nbParticipations = 0, nbOrganisations = 0;
+ public Personne(final String n, final String p) {
+ nom = n; prenom = p;
+ }
+ public void voter(final Bulletin b){ }
+ public void consulterResultat(final Scrutin s) { }
+ public void seRetirerDUnScrutin(final Scrutin s) { }
+}
\ No newline at end of file
diff --git a/example-code/studs/PlageHoraire.java b/example-code/studs/PlageHoraire.java
new file mode 100644
index 0000000..e1bdce4
--- /dev/null
+++ b/example-code/studs/PlageHoraire.java
@@ -0,0 +1,32 @@
+package studs;
+import java.util.Date;
+public class PlageHoraire extends Choix {
+ private Date dateDebut, dateFin;
+ public PlageHoraire(final Date debut, final Date fin) {
+ super();
+ dateDebut = debut;
+ dateFin = fin;
+ }
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (!(obj instanceof PlageHoraire))
+ return false;
+ PlageHoraire other = (PlageHoraire) obj;
+ if (dateDebut == null) {
+ if (other.dateDebut != null)
+ return false;
+ } else if (!dateDebut.equals(other.dateDebut))
+ return false;
+ if (dateFin == null) {
+ if (other.dateFin != null)
+ return false;
+ } else if (!dateFin.equals(other.dateFin))
+ return false;
+ return true;
+ }
+
+}
diff --git a/example-code/studs/Scrutin.java b/example-code/studs/Scrutin.java
new file mode 100644
index 0000000..d15b724
--- /dev/null
+++ b/example-code/studs/Scrutin.java
@@ -0,0 +1,9 @@
+package studs;
+public class Scrutin {
+ private Personne organisateur;
+ private String nomScrutin;
+ public Scrutin(final String nom, final Personne organisateur) {
+ nomScrutin = nom;
+ this.organisateur = organisateur;
+ }
+}
\ No newline at end of file
diff --git a/example-code/studs/Studs.java b/example-code/studs/Studs.java
new file mode 100644
index 0000000..38c8b88
--- /dev/null
+++ b/example-code/studs/Studs.java
@@ -0,0 +1,15 @@
+package studs;
+import java.util.List;
+import java.util.Vector;
+public class Studs {
+ private List lesChoix;
+ private List lesScrutins;
+ private List lesBulletins;
+ private List lesParticipants;
+ public Studs() {
+ lesChoix = new Vector();
+ lesScrutins = new Vector();
+ lesBulletins = new Vector();
+ lesParticipants = new Vector();
+ }
+}
\ No newline at end of file
diff --git a/example-code/studsabstract/Bulletin.java b/example-code/studsabstract/Bulletin.java
new file mode 100644
index 0000000..7417e26
--- /dev/null
+++ b/example-code/studsabstract/Bulletin.java
@@ -0,0 +1,48 @@
+package studsabstract;
+public class Bulletin{
+ private boolean value;
+ private Personne votant;
+ private Scrutin scrutin;
+ private Choix choix;
+ public Bulletin(final Personne p, final Scrutin s,
+ final Choix c, final boolean v) {
+ votant = p;
+ scrutin = s;
+ value = v;
+ choix = c;
+ choix.addBulletin(this);
+ }
+ public boolean getValue() {
+ return value;
+ }
+ public void setValue(final boolean val) {
+ value = val;
+ }
+ public void retirerDuChoix() {
+ choix.retirerBulletin(this);
+ }
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (!(obj instanceof Bulletin))
+ return false;
+ Bulletin other = (Bulletin) obj;
+ if (choix == null) {
+ if (other.choix != null)
+ return false;
+ } else if (!choix.equals(other.choix))
+ return false;
+ if (scrutin == null) {
+ if (other.scrutin != null)
+ return false;
+ } else if (!scrutin.equals(other.scrutin))
+ return false;
+ if (votant == null) {
+ if (other.votant != null)
+ return false;
+ } else if (!votant.equals(other.votant))
+ return false;
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/example-code/studsabstract/Choix.java b/example-code/studsabstract/Choix.java
new file mode 100644
index 0000000..8bc3fb5
--- /dev/null
+++ b/example-code/studsabstract/Choix.java
@@ -0,0 +1,60 @@
+package studsabstract;
+public abstract class Choix {
+ private Bulletin[] lesBulletins;
+ int nbBulletinsPour, nbBulletinsContre, indexBulletins;
+ public Choix() {
+ lesBulletins = new Bulletin[100];
+ indexBulletins = 0;
+ nbBulletinsPour = 0;
+ nbBulletinsContre = 0;
+ }
+ public int addBulletin(Bulletin b) {
+ lesBulletins[indexBulletins++] = b;
+ if(b.getValue()){
+ nbBulletinsPour++ ;
+ } else {
+ nbBulletinsContre++ ;
+ }
+ return indexBulletins;
+ }
+ public int getNbBulletinsPour() {
+ return nbBulletinsPour;
+ }
+ public int getNbBulletinsContre(){
+ return nbBulletinsContre;
+ }
+ public int chercherRang(Bulletin b){
+ for(int i = 0; i < indexBulletins; i++){
+ if(b.equals(lesBulletins[i]))return i;
+ }
+ return -1;
+ }
+ public void retirerBulletin(final Bulletin retrait) {
+ int rang = chercherRang(retrait);
+ if(rang > -1){
+ compacterBulletins(rang);
+ }
+ }
+ public void compacterBulletins(int r){
+ for(int i = r; i < indexBulletins; i++){
+ lesBulletins[i] = lesBulletins[i+1];
+ }
+ indexBulletins --;
+ }
+ public void modifierBulletin(final Bulletin changed) {
+ int rang = chercherRang(changed);
+ if (rang >=0) {
+ Bulletin aChanger = lesBulletins[rang];
+ if (aChanger.getValue() != changed.getValue()) {
+ aChanger.setValue(changed.getValue());
+ }
+ if (aChanger.getValue()) {
+ nbBulletinsContre-- ;
+ nbBulletinsPour++;
+ } else {
+ nbBulletinsContre++ ;
+ nbBulletinsPour--;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/example-code/studsabstract/Personne.java b/example-code/studsabstract/Personne.java
new file mode 100644
index 0000000..59b5cf7
--- /dev/null
+++ b/example-code/studsabstract/Personne.java
@@ -0,0 +1,12 @@
+package studsabstract;
+public class Personne {
+ private String nom, prenom;
+ private int nbParticipations = 0, nbOrganisations = 0;
+
+ public Personne(final String n, final String p) {
+ nom = n; prenom = p;
+ }
+ public void voter(final Bulletin b){ }
+ public void consulterResultat(final Scrutin s) { }
+ public void seRetirerDUnScrutin(final Scrutin s) { }
+}
\ No newline at end of file
diff --git a/example-code/studsabstract/PlageHoraire.java b/example-code/studsabstract/PlageHoraire.java
new file mode 100644
index 0000000..5879c30
--- /dev/null
+++ b/example-code/studsabstract/PlageHoraire.java
@@ -0,0 +1,31 @@
+package studsabstract;
+import java.util.Date;
+public class PlageHoraire extends Choix {
+ private Date dateDebut, dateFin;
+ public PlageHoraire(final Date debut, final Date fin) {
+ super();
+ dateDebut = debut;
+ dateFin = fin;
+ }
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (!(obj instanceof PlageHoraire))
+ return false;
+ PlageHoraire other = (PlageHoraire) obj;
+ if (dateDebut == null) {
+ if (other.dateDebut != null)
+ return false;
+ } else if (!dateDebut.equals(other.dateDebut))
+ return false;
+ if (dateFin == null) {
+ if (other.dateFin != null)
+ return false;
+ } else if (!dateFin.equals(other.dateFin))
+ return false;
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/example-code/studsabstract/Scrutin.java b/example-code/studsabstract/Scrutin.java
new file mode 100644
index 0000000..5214517
--- /dev/null
+++ b/example-code/studsabstract/Scrutin.java
@@ -0,0 +1,9 @@
+package studsabstract;
+public abstract class Scrutin {
+ private Personne organisateur;
+ private String nomScrutin;
+ public Scrutin(final String nom, final Personne organisateur) {
+ nomScrutin = nom;
+ this.organisateur = organisateur;
+ }
+}
\ No newline at end of file
diff --git a/example-code/studsabstract/ScrutinPlagesHoraires.java b/example-code/studsabstract/ScrutinPlagesHoraires.java
new file mode 100644
index 0000000..468614a
--- /dev/null
+++ b/example-code/studsabstract/ScrutinPlagesHoraires.java
@@ -0,0 +1,16 @@
+package studsabstract;
+import java.util.List;
+import java.util.Vector;
+public final class ScrutinPlagesHoraires extends Scrutin {
+ private static int nbTotal = 0;
+ private List plages;
+ public ScrutinPlagesHoraires(final String nom, final Personne organisateur) {
+ super(nom, organisateur);
+ nbTotal++;
+ plages = new Vector();
+ }
+ public int addPlage(final PlageHoraire p){
+ plages.add(p);
+ return plages.size();
+ }
+}
\ No newline at end of file
diff --git a/example-code/studsabstract/Studs.java b/example-code/studsabstract/Studs.java
new file mode 100644
index 0000000..e585df1
--- /dev/null
+++ b/example-code/studsabstract/Studs.java
@@ -0,0 +1,15 @@
+package studsabstract;
+import studs.Personne;
+import studs.Bulletin;
+public class Studs {
+ private Choix[] lesChoix;
+ private Scrutin[] lesScrutins;
+ private Bulletin[] lesBulletins;
+ private Personne[] lesParticipants;
+ public Studs() {
+ lesChoix = new Choix[100];
+ lesScrutins = new Scrutin[100];
+ lesBulletins = new Bulletin[100];
+ lesParticipants = new Personne[100];
+ }
+}
\ No newline at end of file
diff --git a/example-code/studsclone/Personne.java b/example-code/studsclone/Personne.java
new file mode 100644
index 0000000..aefbbbd
--- /dev/null
+++ b/example-code/studsclone/Personne.java
@@ -0,0 +1,38 @@
+package studsclone;
+import java.util.ArrayList;
+import studsabstract.Bulletin;
+public class Personne implements Cloneable {
+ private String nom, prenom;
+ private int nbParticipations = 0, nbOrg = 0;
+ private ArrayList scrutins;
+ public Personne(final String n, final String p) {
+ this.nom = n;
+ this.prenom = p;
+ scrutins = new ArrayList();
+ }
+ public Scrutin organiserScrutin(final String nom) {
+ Scrutin s = new Scrutin(nom,this);
+ scrutins.add(s);
+ nbOrg ++;
+ return s;
+ }
+ /** le clonage est profond, il duplique les objets references. */
+ @Override
+ public Personne clone() throws CloneNotSupportedException {
+ Personne cl = new Personne(new String(nom), new String(prenom));
+ cl.nbParticipations = nbParticipations;
+ cl.nbOrg = nbOrg;
+ for (Scrutin scr : scrutins ) {
+ Scrutin sclone = scr.clone();
+ sclone.setOrganisateur(cl);
+ cl.scrutins.add(sclone);
+ }
+ return cl;
+ }
+ public String getNom() { return nom; }
+ public String getPrenom() {return prenom; }
+ public ArrayList getScrutins() {return scrutins; }
+ public void voter(final Bulletin b){ }
+ public void consulterResultat(Scrutin s) { }
+ public void seRetirerDUnScrutin(Scrutin s) { }
+}
\ No newline at end of file
diff --git a/example-code/studsclone/Scrutin.java b/example-code/studsclone/Scrutin.java
new file mode 100644
index 0000000..979b1c5
--- /dev/null
+++ b/example-code/studsclone/Scrutin.java
@@ -0,0 +1,21 @@
+package studsclone;
+public class Scrutin implements Cloneable {
+ private Personne organisateur;
+ private String nomScrutin;
+ public Scrutin(final String nom, final Personne organisateur) {
+ nomScrutin = nom;
+ this.organisateur = organisateur;
+ }
+ /** le clonage duplique le nom mais ne peut pas modifier l'organisateur. */
+ @Override
+ public Scrutin clone() throws CloneNotSupportedException {
+ return new Scrutin(new String(nomScrutin), organisateur);
+ }
+ /** Methode pour modifier l'organisateur en cas de clonage. */
+ void setOrganisateur(final Personne norg) {
+ organisateur = norg;
+ }
+ public Personne getOrganisateur() {
+ return organisateur;
+ }
+}
\ No newline at end of file
diff --git a/example-code/studsclonedeep/Personne.java b/example-code/studsclonedeep/Personne.java
new file mode 100644
index 0000000..ce3e4e2
--- /dev/null
+++ b/example-code/studsclonedeep/Personne.java
@@ -0,0 +1,36 @@
+package studsclonedeep;
+import java.util.ArrayList;
+
+import studs.Bulletin;
+public class Personne implements Cloneable {
+ private String nom, prenom;
+ private int nbParticipations = 0, nbOrg = 0;
+ private ArrayList scrutins;
+ public Personne(final String n, final String p) {
+ this.nom = n;
+ this.prenom = p;
+ scrutins = new ArrayList();
+ }
+ public Scrutin organiserScrutin(final String nom) {
+ Scrutin s = new Scrutin(nom,this);
+ scrutins.add(s);
+ nbOrg ++;
+ return s;
+ }
+ /** le clonage est profond, il duplique les objets references */
+ @SuppressWarnings("unchecked")
+ @Override
+ public Personne clone() throws CloneNotSupportedException {
+ Personne clone = new Personne(new String(nom), new String(prenom));
+ clone.nbParticipations = nbParticipations;
+ clone.nbOrg = nbOrg;
+ clone.scrutins = (ArrayList) scrutins.clone();
+ return clone;
+ }
+ public String getNom() { return nom; }
+ public String getPrenom() {return prenom; }
+ public ArrayList getScrutins() {return scrutins; }
+ public void voter(final Bulletin b){ }
+ public void consulterResultat(Scrutin s) { }
+ public void seRetirerDUnScrutin(Scrutin s) { }
+}
\ No newline at end of file
diff --git a/example-code/studsclonedeep/Scrutin.java b/example-code/studsclonedeep/Scrutin.java
new file mode 100644
index 0000000..3e06363
--- /dev/null
+++ b/example-code/studsclonedeep/Scrutin.java
@@ -0,0 +1,22 @@
+package studsclonedeep;
+public class Scrutin implements Cloneable {
+ private Personne organisateur;
+ private String nomScrutin;
+ public Scrutin(final String nom, final Personne organisateur) {
+ nomScrutin = nom;
+ this.organisateur = organisateur;
+ }
+ /** le clonage est leger, il duplique les references seulement. */
+ @Override
+ public Scrutin clone() throws CloneNotSupportedException {
+ Scrutin cl = (Scrutin) super.clone();
+ return cl;
+ }
+ /** Methode pour modifier l'organisateur en cas de clonage. */
+ void setOrganisateur(final Personne norg) {
+ organisateur = norg;
+ }
+ public Personne getOrganisateur() {
+ return organisateur;
+ }
+}
\ No newline at end of file
diff --git a/example-code/studsclonelight/Personne.java b/example-code/studsclonelight/Personne.java
new file mode 100644
index 0000000..05bfd25
--- /dev/null
+++ b/example-code/studsclonelight/Personne.java
@@ -0,0 +1,22 @@
+package studsclonelight;
+import java.util.ArrayList;
+import studs.Bulletin;
+public class Personne implements Cloneable {
+ private String nom, prenom;
+ private int nbParticipations = 0, nbOrg = 0;
+ private ArrayList scrutins ;
+ public Personne(String nom, String prenom){
+ this.nom = nom; this.prenom = prenom; scrutins = new ArrayList(); }
+ public Scrutin organiserScrutin(String nom) {
+ scrutins.add(new Scrutin(nom,this)); return scrutins.get(nbOrg++); }
+ @Override
+ public Personne clone() throws CloneNotSupportedException {
+ return (Personne) super.clone();
+ }
+ public String getNom(){return nom;}
+ public String getPrenom(){return prenom;}
+ public ArrayList getScrutins(){return scrutins;}
+ public void voter(Bulletin b){ }
+ public void consulterResultat(Scrutin s) { }
+ public void seRetirerDUnScrutin(Scrutin s) { }
+}
\ No newline at end of file
diff --git a/example-code/studsclonelight/Scrutin.java b/example-code/studsclonelight/Scrutin.java
new file mode 100644
index 0000000..9cbefc1
--- /dev/null
+++ b/example-code/studsclonelight/Scrutin.java
@@ -0,0 +1,22 @@
+package studsclonelight;
+public class Scrutin implements Cloneable {
+ private Personne organisateur;
+ private String nomScrutin;
+ public Scrutin(final String nom, final Personne organisateur) {
+ nomScrutin = nom;
+ this.organisateur = organisateur;
+ }
+ /** le clonage est leger, il duplique les references seulement. */
+ @Override
+ public Scrutin clone() throws CloneNotSupportedException {
+ Scrutin cl = (Scrutin) super.clone();
+ return cl;
+ }
+ /** Methode pour modifier l'organisateur en cas de clonage. */
+ void setOrganisateur(final Personne norg) {
+ organisateur = norg;
+ }
+ public Personne getOrganisateur() {
+ return organisateur;
+ }
+}
\ No newline at end of file
diff --git a/example-code/studsctrs/Personne.java b/example-code/studsctrs/Personne.java
new file mode 100644
index 0000000..f0a6ed0
--- /dev/null
+++ b/example-code/studsctrs/Personne.java
@@ -0,0 +1,18 @@
+package studsctrs;
+import studs.Bulletin;
+import studs.Scrutin;
+public class Personne {
+ private String nom, prenom;
+ private int nbParticipations = 0, nbOrganisations = 0;
+ public Personne(final String n, final String p) {
+ nom = n; prenom = p;
+ }
+ public Personne(final String n, final String p,
+ final int nbp, final int nbo) {
+ nom = n; prenom = p;
+ nbParticipations = nbp; nbOrganisations = nbo;
+ }
+ public void voter(final Bulletin b) { }
+ public void consulterResultat(final Scrutin s) { }
+ public void seRetirerDUnScrutin(final Scrutin s) { }
+}
\ No newline at end of file
diff --git a/example-code/studsctrs/Scrutin.java b/example-code/studsctrs/Scrutin.java
new file mode 100644
index 0000000..3b5859e
--- /dev/null
+++ b/example-code/studsctrs/Scrutin.java
@@ -0,0 +1,9 @@
+package studsctrs;
+public class Scrutin{
+ private Personne organisateur;
+ private String nomScrutin;
+ public Scrutin(String nom, Personne organisateur){
+ nomScrutin = nom;
+ this.organisateur = organisateur;
+ }
+}
\ No newline at end of file
diff --git a/example-code/studsequals/Personne.java b/example-code/studsequals/Personne.java
new file mode 100644
index 0000000..d507d54
--- /dev/null
+++ b/example-code/studsequals/Personne.java
@@ -0,0 +1,21 @@
+package studsequals;
+public class Personne {
+ private String nom, prenom;
+ public Personne(final String nom, final String prenom){
+ this.nom = nom; this.prenom = prenom;
+ }
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (!(obj instanceof Personne)) return false;
+ Personne other = (Personne) obj;
+ if (nom == null) {
+ if (other.nom != null) return false;
+ } else if (!nom.equals(other.nom)) return false;
+ if (prenom == null) {
+ if (other.prenom != null) return false;
+ } else if (!prenom.equals(other.prenom)) return false;
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/example-code/studsorg/Personne.java b/example-code/studsorg/Personne.java
new file mode 100644
index 0000000..f01850e
--- /dev/null
+++ b/example-code/studsorg/Personne.java
@@ -0,0 +1,20 @@
+package studsorg;
+public class Personne {
+ private String nom, prenom;
+ private int nbParticipations = 0, nbOrganisations = 0;
+ private Scrutin[] scrutinsOrganises ;
+ public Personne(final String nom, final String prenom) {
+ this.nom = nom; this.prenom = prenom;
+ scrutinsOrganises = new Scrutin[10];
+ }
+ public Scrutin organiserScrutin(final String nom){
+ Scrutin s = new Scrutin(nom);
+ scrutinsOrganises[nbOrganisations] = s;
+ nbOrganisations ++;
+ return s;
+ }
+ public String toString() {
+ return getClass().getName() + " "+nom+" "+prenom+" nbp "
+ + nbParticipations + " nbo " + nbOrganisations;
+ }
+}
\ No newline at end of file
diff --git a/example-code/studsorg/Scrutin.java b/example-code/studsorg/Scrutin.java
new file mode 100644
index 0000000..31d3e7c
--- /dev/null
+++ b/example-code/studsorg/Scrutin.java
@@ -0,0 +1,13 @@
+package studsorg;
+public class Scrutin{
+ private String nomScrutin;
+ public Scrutin(final String nom) {
+ nomScrutin = nom;
+ }
+ /* @see java.lang.Object#toString() */
+ @Override
+ public String toString() {
+ return "Scrutin [nomScrutin=" + nomScrutin + "]";
+ }
+
+}
\ No newline at end of file
diff --git a/example-code/studsstat/Personne.java b/example-code/studsstat/Personne.java
new file mode 100644
index 0000000..09ebef5
--- /dev/null
+++ b/example-code/studsstat/Personne.java
@@ -0,0 +1,24 @@
+package studsstat;
+public class Personne {
+ private String nom, prenom;
+ private int nbParticipations = 0, nbOrganisations = 0 ;
+ private static int nbTotalParticipations = 0;
+ public Personne(final String nom, final String prenom){
+ this.nom = nom; this.prenom = prenom;
+ }
+ public Personne(final String nom, final String prenom,
+ final int nbp, final int nbo) {
+ this(nom,prenom);
+ nbParticipations = nbp;
+ nbTotalParticipations += nbp;
+ nbOrganisations = nbo;
+ }
+ public static int getNbTotalParticipations() {
+ return nbTotalParticipations;
+ }
+ public String toString() {
+ return nom + " " + prenom + " nbp " + nbParticipations
+ + " nbo " + nbOrganisations + " nbt "
+ + nbTotalParticipations;
+ }
+}
\ No newline at end of file
diff --git a/example-code/studsstat/Scrutin.java b/example-code/studsstat/Scrutin.java
new file mode 100644
index 0000000..35458c4
--- /dev/null
+++ b/example-code/studsstat/Scrutin.java
@@ -0,0 +1,9 @@
+package studsstat;
+public class Scrutin {
+ private Personne organisateur;
+ private String nomScrutin;
+ public Scrutin(final String nom, final Personne organisateur) {
+ nomScrutin = nom;
+ this.organisateur = organisateur;
+ }
+}
\ No newline at end of file
diff --git a/example-code/studsthis/Personne.java b/example-code/studsthis/Personne.java
new file mode 100644
index 0000000..f12d108
--- /dev/null
+++ b/example-code/studsthis/Personne.java
@@ -0,0 +1,19 @@
+package studsthis;
+import studs.Bulletin;
+import studs.Scrutin;
+public class Personne {
+ private String nom, prenom;
+ private int nbParticipations = 0, nbOrganisations = 0;
+
+ public Personne(final String nom, final String prenom) {
+ this.nom = nom; this.prenom = prenom;
+ }
+ public Personne(final String n, final String p,
+ final int nbp, final int nbo) {
+ this(n, p);
+ nbParticipations = nbp; nbOrganisations = nbo;
+ }
+ void voter(final Bulletin b){ }
+ void consulterResultat(final Scrutin s) { }
+ void seRetirerDUnScrutin(final Scrutin s) { }
+}
\ No newline at end of file
diff --git a/oldindex.html b/oldindex.html
new file mode 100644
index 0000000..ded0c54
--- /dev/null
+++ b/oldindex.html
@@ -0,0 +1,413 @@
+
+
+
+
+
+
+ Java Visualizer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+