Question
Scenario: A student has just been taught a design pattern known as the observer pattern. The student is tasked to produce a C# program comprising
Scenario:
A student has just been taught a design pattern known as the observer pattern. The student is tasked to produce a C# program comprising of the following:
A class known as Generator that will at random create a value of type integer within a scope of 1 to 1000 each time a user requests or requires a fresh value. This freshly created value needs to be passed automatically to 2 different type of objects (classes) namely:
Sum - The Sum is responsible for receiving the randomly created value and adding it to the previously created value (should there be no previous value, 0 should be used). Finally, the result should be displayed to the console window.
Date The Date is responsible for receiving the randomly created value and adding it to the current date as number of days. Finally, the date generated should be displayed to the console window.
The application is supposed to loop continuously up until the user pushes the e key on the keyboard to signal the end of the application.
During every loop iteration, the screen must be emptied, a fresh value created or generated and both Date and Sum values should display to the console window.
Since this application is based on the design pattern known as the observer pattern, all interfaces and methods used must support this specified 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