Answered step by step
Verified Expert Solution
Question
1 Approved Answer
You have recently learnt about a design pattern called the Observer pattern. For this scenario you are required to create an application which contains the
You have recently learnt about a design pattern called the Observer pattern. For this scenario you are required to create an application which contains the following: A class called Generator, which randomly generates an integer value in the range 1 to 10000 whenever the user requests a new value. This newly generated value must be automatically passed to two different types of objects (classes): Sum: it should receive the randomly generated value, add it to the previously generated value (if no previous value exists use 0) and then display the result to the console window. o Date: It should receive the randomly generated value, add it to the current date as a number of days and display the generated date to the console window. The program should continuously loop until the user presses the "e" key to end the program. At each iteration of the loop the screen should be cleared, a new random velue generated, and the Sum and Dale values cisplayed on the console window. program should be based on the observer pattern, which means it should include all of the interfaces and methods required to align to this pattern. You have recently learnt about a design pattern called the Observer pattern. For this scenario you are required to create an application which contains the following: A class called Generator, which randomly generates an integer value in the range 1 to 10000 whenever the user requests a new value. This newly generated value must be automatically passed to two different types of objects (classes): Sum: it should receive the randomly generated value, add it to the previously generated value (if no previous value exists use 0) and then display the result to the console window. o Date: It should receive the randomly generated value, add it to the current date as a number of days and display the generated date to the console window. The program should continuously loop until the user presses the "e" key to end the program. At each iteration of the loop the screen should be cleared, a new random velue generated, and the Sum and Dale values cisplayed on the console window. program should be based on the observer pattern, which means it should include all of the interfaces and methods required to align to this pattern
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