Created
September 2, 2018 14:28
-
-
Save DVegasa/b1aa63bbf6ccf1bfd5ea9737381aeffc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
public class DV | |
{ | |
// ============================================================== | |
public static void Main() | |
{ | |
try | |
{ | |
Console.Title = "DV programm"; | |
Console.WindowHeight = 40; | |
Console.ForegroundColor = ConsoleColor.Yellow; | |
Console.WriteLine("____________________________________"); | |
Console.Write(DateTime.Now); | |
Console.WriteLine(" МЕНЮ"); | |
Console.WriteLine(""); | |
Console.WriteLine("1 -- таблица умножения"); | |
Console.WriteLine("2 -- возведение в степень"); | |
Console.WriteLine("3 -- корень числа"); | |
Console.WriteLine("4 -- послушать звуковые сигналы"); | |
Console.WriteLine("5 -- попытать удачу в вводе пароля"); | |
short input = Convert.ToInt16(Console.ReadLine()); | |
Console.WriteLine("____________________________________"); | |
Console.ResetColor(); | |
switch (input) | |
{ | |
case 1: | |
Um(); | |
break; | |
case 2: | |
St(); | |
break; | |
case 3: | |
Console.Write("Ваше число: "); | |
Console.WriteLine("Квадратный корень: "+Math.Sqrt(Convert.ToInt32(Console.ReadLine()))); | |
Main(); | |
break; | |
case 4: | |
Sound(); | |
break; | |
case 5: | |
Password(); | |
break; | |
default: | |
throw new Exception("Вы ввели неверное число"); | |
} | |
Console.ReadLine(); | |
} | |
catch (Exception ex) | |
{ | |
Console.BackgroundColor = ConsoleColor.DarkRed; | |
Console.ForegroundColor = ConsoleColor.White; | |
Console.WriteLine("=====[ ERROR ]====="); | |
Console.WriteLine(""); | |
Console.WriteLine(ex); | |
Console.WriteLine(""); | |
Console.WriteLine("==================="); | |
Console.ResetColor(); | |
Main(); | |
} | |
} | |
// ============================================================== | |
public static void Um() | |
{ | |
Console.WriteLine("Таблица умножения. Нажмите клавишу для просмотра"); | |
for (int i = 1; i < 11; i++) | |
{ | |
Console.ReadKey(true); | |
Console.WriteLine("=========="); | |
for (int i2 = 1; i2 < 11; i2++) | |
{ | |
Console.WriteLine("{0} * {1} = {2}", i, i2, i * i2); | |
} | |
} | |
Main(); | |
} | |
// ============================================================== | |
public static void St() | |
{ | |
Console.WriteLine("Введите число для возведения"); | |
double input = Convert.ToDouble(Console.ReadLine()); | |
Console.WriteLine("Степень | Результат"); | |
for (int i = 1; i < 11; i++) | |
{ | |
Console.WriteLine("{0} | {1}", i, Math.Pow(input, i)); | |
} | |
Main(); | |
} | |
// ================================================================= | |
public static void Sound() | |
{ | |
int freq, dur, n; | |
Console.WriteLine("Укажите частоту звука (от 37 до 32767)"); | |
freq = Convert.ToInt32(Console.ReadLine()); | |
Console.WriteLine("Укажите продолжительность звука (в милисекундах)"); | |
dur = Convert.ToInt32(Console.ReadLine()); | |
Console.WriteLine("Сколько раз повторить звук?"); | |
n = Convert.ToInt32(Console.ReadLine()); | |
Console.ForegroundColor = ConsoleColor.DarkGray; | |
for (int i = 0; i < n; i++) | |
{ | |
Console.WriteLine("*Начато проигрывание звука* ({0})", i+1); | |
Console.Beep(freq, dur); | |
Console.WriteLine("*Проигрывание завершно*"); | |
Console.WriteLine(""); | |
} | |
Console.ResetColor(); | |
Main(); | |
} | |
//===================================================================== | |
public static void Password() | |
{ | |
string pass = "admin"; | |
string input; | |
Console.WriteLine("Введите пароль"); | |
input = Console.ReadLine(); | |
if (input == pass) | |
{ | |
Console.ForegroundColor = ConsoleColor.Green; | |
Console.WriteLine("Успех!"); | |
Console.WriteLine(""); | |
Console.ResetColor(); | |
Main(); | |
} | |
else | |
{ | |
Console.ForegroundColor = ConsoleColor.Red; | |
Console.WriteLine("Неудачно!"); | |
Console.WriteLine(""); | |
Console.ResetColor(); | |
Password(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment