implement in CapteurImp and remove Future and MI

This commit is contained in:
tuanvu
2025-11-06 10:27:55 +01:00
parent b4a2e96f19
commit bee8b50d84
7 changed files with 29 additions and 25 deletions

View File

@@ -7,6 +7,5 @@ public class Afficheur implements ObserverdeCapteur {
//AO1 - concrete servant
@Override
public void update(Capteur subject) {
}
}

View File

@@ -3,16 +3,37 @@ package impl;
import interfaces.Capteur;
import interfaces.Observer;
import java.time.Clock;
import java.util.ArrayList;
import java.util.List;
public class CapteurImpl implements Capteur {
public Clock clock = Clock.systemUTC();
public int value;
public List<Observer<Integer>> observers;
public CapteurImpl() {
value = 0;
observers = new ArrayList<>();
}
@Override
public void attach(Observer o) {
public void attach(Observer<Integer> o) {
try {
observers.add(o);
}catch(Exception e) {
//TODO
e.printStackTrace();
}
}
@Override
public void detach(Observer o) {
public void detach(Observer<Integer> o) {
try {
observers.remove(o);
}catch(Exception e) {
//TODO
e.printStackTrace();
}
}
@Override

View File

@@ -1,10 +1,8 @@
package impl;
import interfaces.MethodInvocation;
public class GetValue implements MethodInvocation {
public class GetValue {
//AO2 - concrete MI
@Override
public void call() {
}

View File

@@ -1,10 +1,7 @@
package impl;
import interfaces.MethodInvocation;
public class Update implements MethodInvocation {
public class Update {
//AO1 - concrete MI
@Override
public void call() {
}

View File

@@ -1,7 +1,7 @@
package interfaces;
public interface Capteur {
public void attach(Observer o);
public void detach(Observer o);
public void attach(Observer<Integer> o);
public void detach(Observer<Integer> o);
public void tick();
//AO2 - servant

View File

@@ -1,6 +0,0 @@
package interfaces;
public interface Future<T> {
T get();
boolean isDone();
}

View File

@@ -1,5 +0,0 @@
package interfaces;
public interface MethodInvocation {
void call();
}