Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Construct a UML class diagram showing how the Observer pattern can be used to keep the LeaderBoard and NewsFeed informed and updated when changes occur

Construct a UML class diagram showing how the Observer pattern can be used to keep the LeaderBoard and NewsFeed informed and updated when changes occur in the Election Results. Be sure to use Javas inbuilt observer pattern. Show key associations between classes and key operations.

How does Java support the Observer role?

How does Java support the Observable role?

image text in transcribed

public class ElectionResults class NewsFeed class LeaderBoard String currentLeader LeaderBoard0 int democrats; int republicans; int crazies; void ElectionResults0 int newsDemocrats; int newsRepublicans; int newsCrazies; currentLeader "Unknown void NewsFeed void postleader(l democrats 0 republicans 0; crazies 0; newsRepublicans 0; System.out.printf("The current leader is %s", currentLeader String getCurrentWinner( // Compute current winner here return currentWinner; System.out.printf("Democrats %d. Republicans %d, Crazies %d" newsDemocrats, newsRepublicans, public static void main(String[] args)i ElectionResults resultsnew ElectionResults); results.addNewResults(10,8,13); results.addNewResults(12,7,8) void addNewResults(int dems, int reps, int craz)I democratst dems; republicans+ reps; crazies+=craz

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_2

Step: 3

blur-text-image_3

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

Advances In Spatial And Temporal Databases 11th International Symposium Sstd 2009 Aalborg Denmark July 8 10 2009 Proceedings Lncs 5644

Authors: Nikos Mamoulis ,Thomas Seidl ,Kristian Torp ,Ira Assent

2009th Edition

3642029817, 978-3642029813

More Books

Students also viewed these Databases questions