Blame view

Porte2Entrees.java 1.36 KB
0498df6f   rsimonin   first commit
1
2
3
4
5
  
  
  public abstract  class Porte2Entrees extends Porte {
      Composant in1,in2;
      Boolean s;
e0205b46   rsimonin   fini
6
  
0498df6f   rsimonin   first commit
7
8
9
10
11
12
13
14
15
16
17
18
19
20
      void setIN1(Composant comp){in1= comp;}
      void setIN2(Composant comp){in2= comp;}
  
      public String description(){
  	String s1 ="non connecté";
  	String s2 ="non connecté";
  	if(in1!=null){s1=in1.getId();}
  	if(in2!=null){s2=in2.getId();}
  	return getId() +" ||in1: " + s1  +" ||in2: "+ s2;
      }
      public abstract boolean eval()throws NonConnecteException;
  
      public void probe(SondesTable tableSondes){
  	if(in1 instanceof Interrupteur){
e0205b46   rsimonin   fini
21
  	    setIN1(tableSondes.getSonde((Interrupteur)in1,in1,in1.getId()));
0498df6f   rsimonin   first commit
22
23
  	}
  	if(in2 instanceof Interrupteur){
e0205b46   rsimonin   fini
24
  	    setIN2(tableSondes.getSonde((Interrupteur)in2,in2,in2.getId()));
0498df6f   rsimonin   first commit
25
26
27
28
  	}
      }
      public void unprobe(SondesTable tableSondes){
  	if(in1 instanceof LazySonde){
e0205b46   rsimonin   fini
29
  	    setIN1(tableSondes.getInterrupteur((LazySonde)in1));
0498df6f   rsimonin   first commit
30
31
  	}
  	if(in2 instanceof LazySonde){
e0205b46   rsimonin   fini
32
  	    setIN2(tableSondes.getInterrupteur((LazySonde)in2));
0498df6f   rsimonin   first commit
33
34
  	}
      }
e0205b46   rsimonin   fini
35
  
0498df6f   rsimonin   first commit
36
      /*public boolean getEtat() throws NonConnecteException {
e0205b46   rsimonin   fini
37
38
  	if ((this.in1 == null) || (this.in2 == null)) {
  	    throw new NonConnecteException();
0498df6f   rsimonin   first commit
39
40
41
42
43
44
45
46
  	}
  	else if(s==null) {
  	    s=this.eval();
  	    return s;
  	}
  	else{ return s;}
  	}*/
      public boolean getEtat() throws NonConnecteException {
e0205b46   rsimonin   fini
47
48
  	if ((this.in1 == null) || (this.in2 == null)) {
  	    throw new NonConnecteException();
0498df6f   rsimonin   first commit
49
50
51
52
  	}
  	else {
  	    return this.eval();
  	}
e0205b46   rsimonin   fini
53
      }
0498df6f   rsimonin   first commit
54
  }