CJCoding With Joseph

Polymorphic Factory From Input

A factory method can return different subclasses through the same base type, chosen at runtime. Notification is abstract with abstract string Format(string); EmailNotification and SmsNotification are complete. In NotificationFactory, finish Create(string type) so it returns an EmailNotification when type is email, and an SmsNotification otherwise. The tester reads the type and message from input. Do NOT write a Main method.

For input email then Hello the program prints:
Email: Hello
For input sms then Hi it prints:
SMS: Hi

Expected Output:

Email: Hello
Topics:
Polymorphism
๐Ÿ“ฅ Auto-Input:
email\nHello\n
This input is automatically fed to your program's stdin
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cw, cr, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.