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 to Expert-Tailored 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

Recommended Textbook for

Data And Information Quality Dimensions, Principles And Techniques

Authors: Carlo Batini, Monica Scannapieco

1st Edition

3319241060, 9783319241067

Students also viewed these Databases questions

Question

What mistakes were made by Oracle?

Answered: 1 week ago

Question

can you help me with a Gantt chart for me please

Answered: 1 week ago

Question

6. Explain what causes unsafe acts.

Answered: 1 week ago