public static void Main(string[] args) { FontAdjustment f = 0; int flag = 0; while (true) { Console.WriteLine($"Параметры надписи: {f} {Environment.NewLine}" + $"Введите: {Environment.NewLine} " + $" 1: bold {Environment.NewLine} " + $" 2: italic {Environment.NewLine} " + $" 3: underline"); flag = int.Parse(Console.ReadLine()); switch (flag) { case 1: f ^= FontAdjustment.Bold; break; case 2: f ^= FontAdjustment.Italic; break; case 3: f ^= FontAdjustment.Underline; break; } } }
static void Main(string[] args) { FontAdjustment MyFont = new FontAdjustment(); int fontParam = 0; do { ShowEnum(MyFont); fontParam = TakeValue(); switch (fontParam) { case 1: MyFont ^= FontAdjustment.bold; break; case 2: MyFont ^= FontAdjustment.italic; break; case 3: MyFont ^= FontAdjustment.underline; break; } } while (fontParam != 4); }
public static void Main(string[] args) { FontAdjustment f = 0; int flag = 0; while (true) { Console.WriteLine($"Inscription parameters: {f} {Environment.NewLine} Enter: {Environment.NewLine} " + $"1: bold {Environment.NewLine} 2: italic {Environment.NewLine} 3: underline"); flag = ReadNumber(); switch (flag) { case 1: f ^= FontAdjustment.bold; break; case 2: f ^= FontAdjustment.italic; break; case 3: f ^= FontAdjustment.underline; break; } } }
static void ShowEnum(FontAdjustment myFont) { Console.WriteLine($"Параметры надписи:{myFont}"); for (int i = 1; i < Enum.GetValues(typeof(FontAdjustment)).Length; i++) { Console.WriteLine($"{i,10}: {Enum.GetValues(typeof(FontAdjustment)).GetValue(i)}"); } }
static void Main(string[] args) { Console.WriteLine("Task №1.1"); Console.Write("Enter a positive integer a: "); if (!int.TryParse(Console.ReadLine(), out int a) || a <= 0) { Console.WriteLine("Incorrect data entered."); } else { Console.Write("Enter a positive integer b: "); if (!int.TryParse(Console.ReadLine(), out int b) || b <= 0) { Console.WriteLine("Incorrect data entered."); } else { Console.WriteLine("The area of the rectangle with the sides {0} and {1}: {2}", a, b, RectangleArea(a, b)); } } Console.WriteLine("Task №1.2"); Console.Write("Enter a positive integer N: "); if (!int.TryParse(Console.ReadLine(), out int n) || n <= 0) { Console.WriteLine("Incorrect data entered."); } else { PrintTriangle(n); } Console.WriteLine("Task №1.3"); Console.Write("Enter a positive integer N: "); if (!int.TryParse(Console.ReadLine(), out int N) || N <= 0) { Console.WriteLine("Incorrect data entered."); } else { PrintBigTriangle(N); } Console.WriteLine("Task №1.4"); Console.Write("Enter a positive integer N: "); if (!int.TryParse(Console.ReadLine(), out int T) || N <= 0) { Console.WriteLine("Incorrect data entered."); } else { XmasTree(T); } Console.WriteLine("Task №1.5"); Console.WriteLine("The sum of all numbers is less than 1000, a multiple of 3 or 5: {0}", SumOfNumbers(1000)); Console.WriteLine("Task №1.6. To exit, press Escape."); FontAdjustment fontAdjustment = 0; while (true) { Console.Write("Inscription parameters: "); if (fontAdjustment == FontAdjustment.Null) { Console.Write("null"); } if (fontAdjustment.HasFlag(FontAdjustment.bold)) { Console.Write("Bold "); } if (fontAdjustment.HasFlag(FontAdjustment.italic)) { Console.Write("Italic "); } if (fontAdjustment.HasFlag(FontAdjustment.underline)) { Console.Write("Underline "); } Console.WriteLine("\nEnter:" + "\n 1: bold" + "\n 2: italic" + "\n 3: underline"); Console.Write("Input: "); if (!int.TryParse(Console.ReadLine(), out int input)) { Console.Write("Incorrect data entered."); return; } else if (input > 0 && input < 4) { if (input == 3) { input++; } FontAdjustment inputFlag = (FontAdjustment)input; if (fontAdjustment.HasFlag(inputFlag)) { fontAdjustment ^= inputFlag; } else { fontAdjustment |= inputFlag; } } } }