Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

draw uml diagram of the code below public class Main { public static void main ( String [ ] args ) { BourseRateTracker rateTracker =

draw uml diagram of the code below
public class Main {
public static void main(String[] args){
BourseRateTracker rateTracker = new BourseRateTracker();
CurrencyDisplay display1= new CurrencyDisplay();
CurrencyDisplay display2= new CurrencyDisplay();
rateTracker.registerObserver(display1);
rateTracker.registerObserver(display2);
rateTracker.setUsdTryRate(8.0);
}
}
import java.util.List;
import java.util.ArrayList;
public class BourseRateTracker implements CurrencyRateTracker {
private List observers = new ArrayList<>();
private double usdTryRate;
public void setUsdTryRate(double rate){
this.usdTryRate = rate;
notifyObservers();
}
@Override
public void registerObserver(Observer o){
observers.add(o);
}
@Override
public void removeObserver(Observer o){
observers.remove(o);
}
@Override
public void notifyObservers(){
for (Observer observer : observers){
observer.update(usdTryRate);
}
}
}
public interface CurrencyRateTracker {
void registerObserver(Observer o);
void removeObserver(Observer o);
void notifyObservers();
}
public class CurrencyDisplay implements Observer {
@Override
public void update(double rate){
System.out.println("Updated USD/TRY Rate: "+ rate);
}
}
public interface Observer {
void update(double usdTryRate);
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

can you help me with a Gantt chart for me please

Answered: 1 week ago