Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started