Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use Delegate and use Window Form Please make sure: No duplication subscription is allowed; in other words, if I try to subscribe using my

Please use Delegate and use Window Form

Please make sure:

No duplication subscription is allowed; in other words, if I try to subscribe using my email multiple times, you app should not allowed it.

Your app should be able to deal with multiple subscribers. [hint: use collections to hold the subscribers information]

In the real world, the notification management system consists of two parts, one is to allow clients to subscribe/unsubscribe the notification, and another part is to facilitate administrator(s) to publish the notification. This assignment simplifies the problem, and merges two parts as one. In this assignment, you are asked to implement a C# application to mimic notification management system. You are required to use delegate.

Your app facilitates clients to subscribe/unsubscribe notification as well as send notification to all subscribers. Your App needs to make sure that the provided email address is valid and provided cell phone number is followed the specified format.

After the app has been launched, following GUI (or similar one) should be presented. As there is no subscriber when the app just launches, Publish Notification button is disabled.

image text in transcribed

After Manage Subscription button clicked, following GUI (or similar one) should be popped up to allow clients to subscribe or unsubscribe notification. If an invalid email address has been provided, error message should be provided.

image text in transcribed

After Publish Notification button clicked, following GUI is presented to facilitate notification publish.

image text in transcribed

Please make sure:

No duplication subscription is allowed; in other words, if I try to subscribe using my email multiple times, you app should not allowed it.

Your app should be able to deal with multiple subscribers. [hint: use collections to hold the subscribers information]

SAMPLE Code

Driver class

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;

namespace MulticastDelegate { class Driver { public static void Main(string[] args) { Publisher publisher = new Publisher(); SendViaMobile sendMobile1 = new SendViaMobile("416 1234567");

SendViaMobile sendMobile2 = new SendViaMobile("416 1239999"); SendViaEmail sendEmail1 = new SendViaEmail("yli@my.centennialcollege.ca");

SendViaEmail sendEmail2 = new SendViaEmail("yli202@my.centennialcollege.ca");

//Subscribing for Mobile notifications sendMobile1.Subscribe(publisher); sendMobile2.Subscribe(publisher);

sendEmail1.Subscribe(publisher); sendEmail2.Subscribe(publisher); //sub2.UnSubscribe(publisher); //Invoking the delegate Only Mobile will receive notifications. publisher.PublishMessage("Hello You Have New Notifications for COMP212"); sendEmail2.UnSubscribe(publisher); publisher.PublishMessage("Hello You Have New Notifications for COMP000"); //sendEmail1.UnSubscribe(publisher);

Console.ReadKey();

} } }

Publisher class

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;

namespace MulticastDelegate { //publisher will notify the message to the subscriber public class Publisher { //Declare Delegate public delegate void PublishMessageDel(string msg);

//Declare an instance variable which is a Delegate object public PublishMessageDel publishmsg = null;

//Method used to Invoke Delegate public void PublishMessage(string message) { //Invoke Delegate publishmsg.Invoke(message); } } }

SendViaEmail class

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;

namespace MulticastDelegate { public class SendViaEmail { public String EmailAddr { get; set; }

public SendViaEmail() { }

public SendViaEmail(String emailAddr) { EmailAddr = emailAddr; }

public void sendEmail(string msg) { Console.WriteLine("The message" + "\""+ msg+ "\" has already sent to "+ EmailAddr); }

public void Subscribe(Publisher pub) { pub.publishmsg += sendEmail; }

public void UnSubscribe(Publisher pub) { pub.publishmsg -= sendEmail; } } }

SendViaMobile class

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;

namespace MulticastDelegate { public class SendViaMobile { public String CellPhone { get; set; }

public SendViaMobile() { }

public SendViaMobile(String phone) { CellPhone = phone; }

private void sendMessage(string msg) { Console.WriteLine("The message "+ "\"" + msg+ "\" has already texted to " + CellPhone ); }

public void Subscribe(Publisher pub) { pub.publishmsg += sendMessage; }

public void UnSubscribe(Publisher pub) { pub.publishmsg -= sendMessage; } } }

Notification Manager Manage Subscription Publish Notification Exit Notification Sent by Email Invalide email address Notification Sent By SMS Nitification Content

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_2

Step: 3

blur-text-image_3

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

AWS Certified Database Study Guide Specialty DBS-C01 Exam

Authors: Matheus Arrais, Rene Martinez Bravet, Leonardo Ciccone, Angie Nobre Cocharero, Erika Kurauchi, Hugo Rozestraten

1st Edition

1119778956, 978-1119778950

More Books

Students also viewed these Databases questions

Question

How will investors get their money back?

Answered: 1 week ago

Question

How will I represent this new problem?

Answered: 1 week ago

Question

Learn about HRM development in Poland in recent years.

Answered: 1 week ago