Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ArraysLab
- {
- class Program
- {
- static void Main()
- {
- int n = int.Parse(Console.ReadLine());
- Message(n);
- }
- static int Message(int n)
- {
- for (int i = 0; i < n; i++)
- {
- string input = Console.ReadLine();
- if (input == "success")
- {
- string operation = Console.ReadLine();
- string message = Console.ReadLine();
- Console.WriteLine(ShowSuccess(operation, message));
- }
- else if (input == "error")
- {
- string operation = Console.ReadLine();
- int code = int.Parse(Console.ReadLine());
- Console.WriteLine(ShowError(operation, code));
- }
- else
- {
- continue;
- }
- }
- }
- static string ShowSuccess(string operation, string message)
- {
- string result = String.Empty;
- Console.WriteLine("Successfully executed {0}.", operation);
- Console.WriteLine("==============================");
- Console.WriteLine("Message: {0}.", message);
- return result;
- }
- static string ShowError(string operation, int code)
- {
- string reason = String.Empty;
- if (code >= 0)
- {
- reason = "Invalid Client Data";
- }
- else
- {
- reason = "Internal System Failure";
- }
- Console.WriteLine("Error: Failed to execute {0}.", operation);
- Console.WriteLine("==============================");
- Console.WriteLine("Error Code: {0}.", code);
- Console.WriteLine("Reason: {0}.", reason);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment