Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 align to this pattern.

For example. The C# application should have interfaces such as IObserver and ISubject and include methods such as update(), Attach(), Detach(), Notify() or any relevant classes and methods appropriate for above mentioned project.

The application must be developed in C#

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions