diff --git a/And.class b/And.class index 15daabb..577724b 100644 Binary files a/And.class and b/And.class differ diff --git a/And.java b/And.java index e77b711..d682088 100644 --- a/And.java +++ b/And.java @@ -5,15 +5,15 @@ public class And extends Porte2Entrees{ void display(){ }*/ /*public boolean getEtat() throws NonConnecteException { - if ((in1 == null) || (in2 == null)) { - throw new NonConnecteException(); + if ((in1 == null) || (in2 == null)) { + throw new NonConnecteException(); } else { s=(in1.getEtat() && in2.getEtat()); - return s; - } + return s; + } }*/ public boolean eval()throws NonConnecteException { - return (in1.getEtat() && in2.getEtat()); + return (in1.getEtat() & in2.getEtat()); } } diff --git a/LazySonde.class b/LazySonde.class index 2e68932..c2a3b9d 100644 Binary files a/LazySonde.class and b/LazySonde.class differ diff --git a/LazySonde.java b/LazySonde.java index 5754b75..c739911 100644 --- a/LazySonde.java +++ b/LazySonde.java @@ -12,16 +12,16 @@ public class LazySonde extends Sonde{ str1=null; } public boolean getEtat() throws NonConnecteException{ - System.out.println(" je suis lazy SONNNNDEE"); + //System.out.println(" je suis lazy SONNNNDEE"); Scanner sc = new Scanner(System.in); - if (str1 == null) { - throw new NonConnecteException(); + if (str1 == null) { + throw new NonConnecteException(); } else if(valsor!=null){return valsor;} else { System.out.println(str1+ " de " + c1 + " ,true ou false ? " ); - + if (sc.hasNextBoolean()) { valsor = sc.nextBoolean(); return valsor; @@ -29,10 +29,10 @@ public class LazySonde extends Sonde{ else { System.out.println("Nous avons pas compris votre choix, la valeur par default est false !"); return false; - } + } } } - + public void reset(){ valsor=null; return ; diff --git a/Not.class b/Not.class index faa9936..56046f9 100644 Binary files a/Not.class and b/Not.class differ diff --git a/Not.java b/Not.java index f960ced..ed10ec1 100755 --- a/Not.java +++ b/Not.java @@ -4,37 +4,37 @@ */ public class Not extends Porte { - + protected Composant in; - - public void setIn(Composant comp) { - in = comp; + + public void setIn(Composant comp) { + in = comp; } public void probe(SondesTable tableSondes){ if(in instanceof Interrupteur){ - System.out.println(tableSondes.getSonde((Interrupteur)in,in,in.getId())); + setIn(tableSondes.getSonde((Interrupteur)in,in,in.getId())); } } public String description(){ return getId() + " ||in: "+ in.getId(); } - + public boolean getEtat() throws NonConnecteException { - + if (in == null) { - + throw new NonConnecteException(); - + } else { - + return !in.getEtat(); - + } } public void unprobe(SondesTable tableSondes){ if(in instanceof LazySonde){ - System.out.println(tableSondes.getInterrupteur((LazySonde)in)); + setIn(tableSondes.getInterrupteur((LazySonde)in)); } } } diff --git a/Or.class b/Or.class index 54f0a87..75dd37c 100644 Binary files a/Or.class and b/Or.class differ diff --git a/Or.java b/Or.java index 51b9c10..b25dcac 100644 --- a/Or.java +++ b/Or.java @@ -6,16 +6,16 @@ public class Or extends Porte2Entrees{ }*/ /*public boolean getEtat() throws NonConnecteException { - if ((in1 == null) || (in2 == null)) { - throw new NonConnecteException(); + if ((in1 == null) || (in2 == null)) { + throw new NonConnecteException(); } else { s=(in1.getEtat() || in2.getEtat()); - return s; - } + return s; + } }*/ public boolean eval() throws NonConnecteException{ - return (in1.getEtat() || in2.getEtat()); + return (in1.getEtat() | in2.getEtat()); } - + } diff --git a/Porte2Entrees.class b/Porte2Entrees.class index 867f25b..01b57fe 100644 Binary files a/Porte2Entrees.class and b/Porte2Entrees.class differ diff --git a/Porte2Entrees.java b/Porte2Entrees.java index 07e567f..22b4b63 100644 --- a/Porte2Entrees.java +++ b/Porte2Entrees.java @@ -3,7 +3,7 @@ public abstract class Porte2Entrees extends Porte { Composant in1,in2; Boolean s; - + void setIN1(Composant comp){in1= comp;} void setIN2(Composant comp){in2= comp;} @@ -18,24 +18,24 @@ public abstract class Porte2Entrees extends Porte { public void probe(SondesTable tableSondes){ if(in1 instanceof Interrupteur){ - tableSondes.getSonde((Interrupteur)in1,in1,in1.getId()); + setIN1(tableSondes.getSonde((Interrupteur)in1,in1,in1.getId())); } if(in2 instanceof Interrupteur){ - tableSondes.getSonde((Interrupteur)in2,in2,in2.getId()); + setIN2(tableSondes.getSonde((Interrupteur)in2,in2,in2.getId())); } } public void unprobe(SondesTable tableSondes){ if(in1 instanceof LazySonde){ - tableSondes.getInterrupteur((LazySonde)in1); + setIN1(tableSondes.getInterrupteur((LazySonde)in1)); } if(in2 instanceof LazySonde){ - tableSondes.getInterrupteur((LazySonde)in2); + setIN2(tableSondes.getInterrupteur((LazySonde)in2)); } } - + /*public boolean getEtat() throws NonConnecteException { - if ((this.in1 == null) || (this.in2 == null)) { - throw new NonConnecteException(); + if ((this.in1 == null) || (this.in2 == null)) { + throw new NonConnecteException(); } else if(s==null) { s=this.eval(); @@ -44,11 +44,11 @@ public abstract class Porte2Entrees extends Porte { else{ return s;} }*/ public boolean getEtat() throws NonConnecteException { - if ((this.in1 == null) || (this.in2 == null)) { - throw new NonConnecteException(); + if ((this.in1 == null) || (this.in2 == null)) { + throw new NonConnecteException(); } else { return this.eval(); } - } + } } diff --git a/SondesTable.class b/SondesTable.class index c031fcf..4089ba8 100644 Binary files a/SondesTable.class and b/SondesTable.class differ diff --git a/SondesTable.java b/SondesTable.java index 1a56db2..b9a0ae0 100644 --- a/SondesTable.java +++ b/SondesTable.java @@ -4,13 +4,13 @@ public class SondesTable{ Map sondetointerrupteur = new HashMap(); Map interrupteurtosonde = new HashMap(); - + public Interrupteur getInterrupteur(LazySonde sonde){ return sondetointerrupteur.get(sonde); } - + public LazySonde getSonde(Interrupteur interrupteur,Composant cible, String entree){ - + if(interrupteurtosonde.containsKey(interrupteur)){ return interrupteurtosonde.get(interrupteur) ; } @@ -18,7 +18,7 @@ public class SondesTable{ LazySonde lz1= new LazySonde(cible,entree); interrupteurtosonde.put(interrupteur,lz1); sondetointerrupteur.put(lz1,interrupteur); - return interrupteurtosonde.get(interrupteur) ; + return lz1 ; } } public void resetSondes(){ @@ -34,5 +34,5 @@ public class SondesTable{ return ; } - + } diff --git a/TestCircuits.class b/TestCircuits.class index 6e06709..6632fe3 100644 Binary files a/TestCircuits.class and b/TestCircuits.class differ diff --git a/TestCircuits.java b/TestCircuits.java index 148d86e..d7c59fc 100755 --- a/TestCircuits.java +++ b/TestCircuits.java @@ -5,7 +5,7 @@ import java.util.Scanner; */ public class TestCircuits { - + public static void main(String[] args) { //Construction Composant tabcomp[]= new Composant[7] ; @@ -23,33 +23,34 @@ public class TestCircuits { tabcomp[4]=i2; tabcomp[5]=i3; tabcomp[6]=v1; - - + + //Connexions - + ((Or)tabcomp[0]).setIN1(tabcomp[3]); - + ((Or)tabcomp[0]).setIN2(tabcomp[4]); ((Not)tabcomp[2]).setIn(tabcomp[5]); ((And)tabcomp[1]).setIN1(tabcomp[0]); ((And)tabcomp[1]).setIN2(tabcomp[2]); ((Vanne)tabcomp[6]).setIn(tabcomp[1]); - + c1.setIN1(new LazySonde(c1,"in1")); - + Circuit cir = new Circuit("circ",tabcomp); test(cir); - + //Affichage //c1.setIN1(new LazySonde(c1,"in1")); - + System.out.println("Au revoir!"); } static void test(Circuit circ){ - circ.unprobe(); + + circ.probe(); /*System.out.println("Nomenclature:"); System.out.println(circ.nomenclature()); System.out.println(); @@ -64,16 +65,17 @@ public class TestCircuits { System.out.println();*/ System.out.println("trace:"); circ.traceEtats(); - + System.out.println(circ.getIns()); System.out.println(circ.getOuts()); - circ.probe(); + circ.unprobe(); + //circ.resetSondes(); - - + + } - + static void printIds(Composant[] tabc){ for(Composant r : tabc){ System.out.println(r.getId()); @@ -82,13 +84,13 @@ public class TestCircuits { static void description(Composant[] tabc){ for(Composant r : tabc){ System.out.println(r.description()); - } + } } - + static void traceEtats(Composant[] tabc){ for(Composant r : tabc){ System.out.println( r.traceEtat() ); - + } } } -- libgit2 0.21.2