Blame view

LazySonde.java~ 824 Bytes
0498df6f   rsimonin   first commit
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
  import java.util.Scanner;
  public class LazySonde extends Sonde{
      Boolean valsor;
  
      LazySonde(Composant c, String str){
  	c1=c;
  	str1=str;
      }
  
      LazySonde(){
  	c1=null;
  	str1=null;
      }
      public boolean getEtat() throws NonConnecteException{
  	System.out.println(" je suis lazy SONNNNDEE");
  	Scanner sc = new Scanner(System.in);
  	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;
  	    }
  	    else {
  		System.out.println("Nous avons pas compris votre choix, la valeur par default est false !");
  		return false;
  	    }    
  	}
      }
      
      public void reset(){
  	this.valsor=null;
  	return ;
      }
  }