Advertisement
HristoGrigorov

Notifications

Feb 10th, 2017
516
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _106.Notifications
  8. {
  9. class Notifications
  10. {
  11. static void Main(string[] args)
  12. {
  13. int numberOfCommands = int.Parse(Console.ReadLine());
  14.  
  15. while (numberOfCommands > 0)
  16. {
  17. string result = Console.ReadLine();
  18. string operation = Console.ReadLine();
  19.  
  20. if (result == "success")
  21. {
  22.  
  23. string message = Console.ReadLine();
  24. string successCommand = ShowSuccess(operation, message);
  25.  
  26. Console.WriteLine(successCommand);
  27. }
  28. else if (result == "error")
  29. {
  30. int code = int.Parse(Console.ReadLine());
  31. string errorCommand = ShowError(operation, code);
  32.  
  33. Console.WriteLine(errorCommand);
  34. }
  35.  
  36. numberOfCommands--;
  37. }
  38. }
  39.  
  40. private static string ShowError(string operation, int code)
  41. {
  42. if (code > 0)
  43. {
  44. string result = $"Error: Failed to execute {operation}.\n==============================\nError Code: {code}.\nReason: Invalid Client Data.";
  45. return result;
  46. }
  47.  
  48. else
  49. {
  50. string result = $"Error: Failed to execute {operation}.\n==============================\nError Code: {code}.\nReason: Internal System Failure.";
  51. return result;
  52. }
  53. }
  54.  
  55. private static string ShowSuccess(string operation, string message)
  56. {
  57. string result = $"Successfully executed {operation}.\n==============================\nMessage: {message}.";
  58. return result;
  59.  
  60. }
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement