Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

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

Seven NoSQL Databases In A Week Get Up And Running With The Fundamentals And Functionalities Of Seven Of The Most Popular NoSQL Databases

Authors: Aaron Ploetz ,Devram Kandhare ,Sudarshan Kadambi ,Xun Wu

1st Edition

1787288862, 978-1787288867

More Books

Students also viewed these Databases questions

Question

Evaluate 3x - x for x = -2 Answer:

Answered: 1 week ago

Question

What is group replacement? Explain with an example. (2-3 lines)

Answered: 1 week ago