Advertisement
Vapio

task9

Mar 6th, 2021 (edited)
676
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.73 KB | None | 0 0
  1. using System;
  2.  
  3. public class Program
  4. {
  5.     public static void Main()
  6.     {
  7.         int consoleColorCount = ConsoleColor.GetNames(typeof(ConsoleColor)).Length;
  8.         uint darkCyanNumber = 3;
  9.         uint whiteNumber = 15;
  10.  
  11.         string userName = "";
  12.         string userPassword = "";
  13.  
  14.         string chooseMenuInput;
  15.         uint chooseColorInput;
  16.  
  17.         bool isRun = true;
  18.         bool isChangeColor;
  19.  
  20.         while (isRun)
  21.         {
  22.             Console.WriteLine("\nWhat do you want to do : ");
  23.             Console.WriteLine("CreateUser\n" +
  24.                               "ChangePassword\n" +
  25.                               "GetName\n" +
  26.                               "ChangeTextColor\n" +
  27.                               "ChangeBackgroundColor\n" +
  28.                               "Esc");
  29.             chooseMenuInput = Console.ReadLine();
  30.  
  31.             switch (chooseMenuInput)
  32.             {
  33.                 case "CreateUser":
  34.                     Console.WriteLine("\nPlease input name of user : ");
  35.                     userName = Console.ReadLine();
  36.                     Console.WriteLine("Please input password of user : ");
  37.                     userPassword = Console.ReadLine();
  38.                     break;
  39.                 case "ChangePassword":
  40.                     if (String.IsNullOrEmpty(userPassword) == false)
  41.                     {
  42.                         Console.WriteLine("\nPlease input a new password : ");
  43.                         userPassword = Console.ReadLine();
  44.                     }
  45.                     else
  46.                     {
  47.                         Console.WriteLine("\nPlease CreateUser to ChangePassword.");
  48.                     }
  49.                     break;
  50.                 case "GetName":
  51.                     if (String.IsNullOrEmpty(userName) == false)
  52.                     {
  53.                         Console.WriteLine("\nUser name is : " + userName);
  54.                     }
  55.                     else
  56.                     {
  57.                         Console.WriteLine("\nPlease CreateUser to GetName.");
  58.                     }
  59.                     break;
  60.                 case "ChangeTextColor":
  61.                     isChangeColor = true;
  62.                     while (isChangeColor)
  63.                     {
  64.                         Console.WriteLine("\nChoose colors of text : ");
  65.                         Console.WriteLine("0. Black\n" +
  66.                                           "1.DarkBlue\n" +
  67.                                           "2.DarkGreen\n" +
  68.                                           "4.DarkRed\n" +
  69.                                           "5.DarkMagenta\n" +
  70.                                           "6.DarkYellow\n" +
  71.                                           "7.Gray\n" +
  72.                                           "8.DarkGray\n" +
  73.                                           "9.Blue\n" +
  74.                                           "10.Green\n" +
  75.                                           "11.Cyan\n" +
  76.                                           "12.Red\n" +
  77.                                           "13.Magenta\n" +
  78.                                           "14.Yellow\n" +
  79.                                           "15.White");
  80.                         chooseColorInput = Convert.ToUInt32(Console.ReadLine());
  81.  
  82.                         if (chooseColorInput < consoleColorCount && chooseColorInput != darkCyanNumber)
  83.                         {
  84.                             Console.ForegroundColor = (ConsoleColor) chooseColorInput;
  85.                             isChangeColor = false;
  86.                         }
  87.                         else
  88.                         {
  89.                             Console.WriteLine("Please input number of color in range.");
  90.                         }
  91.                     }
  92.                     break;
  93.                 case "ChangeBackgroundColor":
  94.                     Console.WriteLine();
  95.                     isChangeColor = true;
  96.                     while (isChangeColor)
  97.                     {
  98.                         Console.WriteLine("\nChoose colors of text : ");
  99.                         Console.WriteLine("0. Black\n" +
  100.                                           "1.DarkBlue\n" +
  101.                                           "2.DarkGreen\n" +
  102.                                           "3.DarkCyan\n" +
  103.                                           "4.DarkRed\n" +
  104.                                           "5.DarkMagenta\n" +
  105.                                           "6.DarkYellow\n" +
  106.                                           "7.Gray\n" +
  107.                                           "8.DarkGray\n" +
  108.                                           "9.Blue\n" +
  109.                                           "10.Green\n" +
  110.                                           "11.Cyan\n" +
  111.                                           "12.Red\n" +
  112.                                           "13.Magenta\n" +
  113.                                           "14.Yellow");
  114.                         chooseColorInput = Convert.ToUInt32(Console.ReadLine());
  115.  
  116.                         if (chooseColorInput < consoleColorCount && chooseColorInput != whiteNumber)
  117.                         {
  118.                             Console.BackgroundColor = (ConsoleColor) chooseColorInput;
  119.                             isChangeColor = false;
  120.                         }
  121.                         else
  122.                         {
  123.                             Console.WriteLine("Please input number of color in range.");
  124.                         }
  125.                     }
  126.                     break;
  127.                 case "Esc":
  128.                     isRun = false;
  129.                     break;
  130.                 default:
  131.                     Console.WriteLine("\nPlease input name of command correctly.");
  132.                     break;
  133.             }
  134.         }
  135.     }
  136. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement