BubaLazi

Notifications-NOT Finished

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