Answered step by step
Verified Expert Solution
Question
00
1 Approved Answer
SE 350: worksheet #2. Observer public class ElectionResults class NewsFeed class LeaderBoard int democrats int republicans; int crazies int newsDemocrats int newsRepublicans; int newsCrazies; String
SE 350: worksheet #2. Observer public class ElectionResults class NewsFeed class LeaderBoard int democrats int republicans; int crazies int newsDemocrats int newsRepublicans; int newsCrazies; String currentLeader; LeaderBoard) currentLeader = "Unknown"; void ElectionResults( void NewsFeed democrats = 0; republicans 0 crazies 0 void postleader)t newsDemocrats = 0; newsRepublicans 0 newsCrazies 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", public static void main(Stringll a newsDemocrats, newsRepublicans newsCrazies); ElectionResults results = new ElectionResults(); results.addNewResults(10,8,13): results.addNewResults(12,7,8) void addNewResults(int dems, int reps, int craz)M democrats+edems; republicanst-reps; crazies+scraz 0 What does this code do? Sketch out the generic class diagram for the Observer pattern. 0 How does java support the Observer role? O How does java support the Observable role? 0 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 Java's inbuilt observer pattern. Show key associations between classes and key operations
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered 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