Question: The live bourse tracking system codes you created for the observer pattern usage example are as follows, but they do not work. I think the
The live bourse tracking system codes you created for the observer pattern usage example are as follows, but they do not work. I think the main function is missing. Complete it so it works and draw the uml diagram of the final version of the code.
Subject interface
public interface CurrencyRateTracker
void registerObserverObserver o;
void removeObserverObserver o;
void notifyObservers;
Concrete Subject
public class BourseRateTracker implements CurrencyRateTracker
private List observers new ArrayList;
private double usdTryRate;
public void setUsdTryRatedouble rate
this.usdTryRate rate;
notifyObservers;
@Override
public void registerObserverObserver o
observers.addo;
@Override
public void removeObserverObserver o
observers.removeo;
@Override
public void notifyObservers
for Observer observer : observers
observer.updateusdTryRate;
Observer interface
public interface Observer
void updatedouble usdTryRate;
Concrete Observer
public class CurrencyDisplay implements Observer
@Override
public void updatedouble rate
System.out.printlnUpdated USDTRY Rate: rate;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
