Design a notification center that can send messages through Email, SMS, and Push channels. Every channel has a destination and can identify itself, but each one renders messages differently.
The provided NotificationCenter class supports these operations:
NotificationCenter() creates a center with no channels.int addEmail(String to) adds an Email channel and returns its index.int addSms(String phone) adds an SMS channel and returns its index.int addPush(String device) adds a Push channel and returns its index.int count() returns how many channels have been added.String channelOf(int index) returns "email", "sms" or "push".String send(int index, String message) returns what that channel produces.String[] sendAll(String message) returns what every channel produces, in the order they were added.Each channel owns its rendering rule:
"EMAIL to <to>: <message>" without changing the message."SMS to <phone>: <message>", shortening messages longer than 20 characters to their first 20 characters."PUSH to <device>: <MESSAGE>", converting the message to uppercase.Indexes are assigned in the order channels are added, starting at 0. An index outside that range returns "UNKNOWN" from both send and channelOf.
Your task is to implement the abstract Alert base class and the concrete EmailAlert, SmsAlert, and PushAlert subclasses. Do not modify the provided NotificationCenter class. The center should be able to call channel and render through the shared type without checking which concrete channel it holds.
Input:
Output:
Explanation: The Email and SMS channels are stored at indices 0 and 1. Email preserves the full message, while SMS keeps only its first 20 characters. Those decisions are made by the channel objects, not by the center.
Input:
Output:
Explanation: The Push channel converts the message to uppercase. Calling send directly and calling sendAll produce the same output because both delegate to the channel's render method.
1 <= to.length, phone.length, device.length <= 300 <= message.length <= 10020 channels are added to one center.100 calls in total are made across all methods.Full marks when all three channels share one type and the center calls the same method on whichever it holds, so each channel decides its own wording. Lose points heavily when `send` branches on a channel name or a stored kind tag to choose the format.
Full marks when the SMS length limit and the push capitalisation live inside their own channels. Lose points when either transformation is applied by the center before handing the message over, or when the limit appears outside the SMS channel.
Full marks when `sendAll` renders every channel in the order they were added using the same call `send` uses, and an out-of-range index returns `UNKNOWN` from both `send` and `channelOf`. Lose points when the two disagree for any input or for printing to stdout.
Passing every test is not enough on its own. A submission is accepted only when the design also clears the bar.
| Call | Returns |
|---|---|
| new NotificationCenter() | null |
| addEmail("alice@mail.com") | 0 |
| addSms("9876543210") | 1 |
| send(0, "Your order has shipped") | "EMAIL to alice@mail.com: Your order has shipped" |
| send(1, "Your order has shipped") | "SMS to 9876543210: Your order has shipp" |
| count() | 2 |
The same message reaches an email and an SMS channel. Email sends it whole, SMS shortens it to twenty characters, and neither decision was made by the center.
Run checks these cases. Submit also runs a larger hidden set.

