Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _13.Notifications
- {
- class Program
- {
- static void Main(string[] args)
- {
- var n = int.Parse(Console.ReadLine());
- for (int i = 0; i < n; i++)
- {
- ReadAndProcessMessage();
- Console.WriteLine();
- }
- }
- static void ReadAndProcessMessage()
- {
- string messageType = Console.ReadLine();
- if (messageType == "success")
- {
- string operation = Console.ReadLine();
- string message = Console.ReadLine();
- ShowSuccessMessage(operation, message);
- }
- else if (messageType == "warning")
- {
- string warningmessage = Console.ReadLine();
- ShowWarningMessage(warningmessage);
- }
- else if (messageType == "error")
- {
- string operation = Console.ReadLine();
- string errormessage = Console.ReadLine();
- int errorCode = int.Parse(Console.ReadLine());
- ShowErrorMessage(operation, errormessage, errorCode);
- }
- }
- static void ShowSuccessMessage(string operation, string message)
- {
- string head = "Successfully executed " + operation + ".";
- Console.WriteLine(head);
- Console.WriteLine(new string('=', head.Length));
- Console.WriteLine("{0}.", message);
- }
- static void ShowWarningMessage(string warningmessage)
- {
- string head = "Warning: " + warningmessage + ".";
- Console.WriteLine(head);
- Console.WriteLine(new string('=', head.Length));
- }
- static void ShowErrorMessage(string operation, string errormessage, int errorCode)
- {
- string head = "Error: Failed to execute " + operation + ".";
- Console.WriteLine(head);
- Console.WriteLine(new string('=', head.Length));
- Console.WriteLine("Reason: {0}.", errormessage);
- Console.WriteLine("Error code: {0}.", errorCode);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement