IPetrov007

Notifications

Feb 2nd, 2017
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 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 _06_Notification
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int n = int.Parse(Console.ReadLine());
  14.  
  15. for (int i = 0; i < n; i++)
  16. {
  17. string result = Console.ReadLine();
  18.  
  19. if (result=="succes")
  20. {
  21. string operation = Console.ReadLine();
  22. string message = Console.ReadLine();
  23.  
  24. ShowSuccess(operation, message);
  25. }
  26. else if (result == "error")
  27. {
  28. string operation1 = Console.ReadLine();
  29. int code = int.Parse(Console.ReadLine());
  30.  
  31. ShowError(operation1, code);
  32. }
  33. }
  34. }
  35. static void ShowSuccess(string operation, string message)
  36. {
  37. var result = $"Successfully executed {operation}." + Environment.NewLine;
  38. result += "==============================" + Environment.NewLine;
  39. result += $"Message: {message}.";
  40. Console.WriteLine(result);
  41. }
  42.  
  43. static void ShowError(string operation1, int code)
  44. {
  45.  
  46.  
  47. var result = $"Error: Failed to execute {operation1}." + Environment.NewLine;
  48. result += "==============================" + Environment.NewLine;
  49. result += $"Error Code: {code}." + Environment.NewLine;
  50.  
  51. string reason = String.Empty;
  52. if (code >= 0)
  53. {
  54. reason = "Invalid Client Data";
  55. }
  56. else
  57. {
  58. reason = "Internal System Failure";
  59. }
  60. result += $"Reason: {reason}.";
  61. Console.WriteLine(result);
  62. }
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment