31 lines
724 B
Java
31 lines
724 B
Java
package impl;
|
|
|
|
import interfaces.CapteurAsync;
|
|
import interfaces.ObserverdeCapteur;
|
|
|
|
import java.util.Random;
|
|
import java.util.concurrent.Future;
|
|
|
|
public class Afficheur implements ObserverdeCapteur {
|
|
private int id= new Random().nextInt(100);
|
|
|
|
public Afficheur() {}
|
|
|
|
public void setId(int id){
|
|
this.id = id;
|
|
}
|
|
|
|
//AO1 - concrete servant
|
|
@Override
|
|
public void update(CapteurAsync capteurAsync) {
|
|
try{
|
|
Future<Integer> futureValue= capteurAsync.getValue();
|
|
Integer value=futureValue.get();
|
|
System.out.println("Afficheur " + id+", value: "+ value);
|
|
}catch(Exception e){
|
|
//TODO
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|