Advertisement
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;
- using System.Threading.Tasks;
- namespace MicroWave
- {
- class Program
- {
- static void Main(string[] args)
- {
- Microwave Microwave_1 = new Microwave("LG", "MS2042DY");
- Microwave_1.Print();
- int power_op = 1, temp_op = 1, weight_op = 1, time_op=1;
- while (true)
- {
- char key = Console.ReadKey().KeyChar;
- switch (key)
- {
- case '1':
- Microwave_1.SwitchON_OFF();
- break;
- case '2':
- Microwave_1.PreviousMode();
- break;
- case '3':
- Microwave_1.NextMode();
- break;
- case 'q':
- case 'Q':
- case 'й':
- case 'Й':
- power_op = 1;
- Microwave_1.DecreasePower(power_op);
- break;
- case 'w':
- case 'W':
- case 'ц':
- case 'Ц':
- power_op = 1;
- Microwave_1.IncreasePower(power_op);
- break;
- case 'e':
- case 'E':
- case 'у':
- case 'У':
- power_op=2;
- Microwave_1.DecreasePower(power_op);
- break;
- case 'r':
- case 'R':
- case 'к':
- case 'К':
- power_op = 2;
- Microwave_1.IncreasePower(power_op);
- break;
- case 'a':
- case 'A':
- case 'ф':
- case 'Ф':
- temp_op = 1;
- Microwave_1.DecreaseTemperature(temp_op);
- break;
- case 's':
- case 'S':
- case 'ы':
- case 'Ы':
- temp_op = 1;
- Microwave_1.IncreaseTemperature(temp_op);
- break;
- case 'd':
- case 'D':
- case 'в':
- case 'В':
- temp_op = 2;
- Microwave_1.DecreaseTemperature(temp_op);
- break;
- case 'f':
- case 'F':
- case 'а':
- case 'А':
- temp_op = 2;
- Microwave_1.IncreaseTemperature(temp_op);
- break;
- case 'z':
- case 'Z':
- case 'я':
- case 'Я':
- weight_op = 1;
- Microwave_1.DecreaseWeight(weight_op);
- break;
- case 'x':
- case 'X':
- case 'ч':
- case 'Ч':
- weight_op = 1;
- Microwave_1.IncreaseWeight(weight_op);
- break;
- case 'c':
- case 'C':
- case 'с':
- case 'С':
- weight_op = 2;
- Microwave_1.DecreaseWeight(weight_op);
- break;
- case 'v':
- case 'V':
- case 'м':
- case 'М':
- weight_op = 2;
- Microwave_1.IncreaseWeight(weight_op);
- break;
- case '4':
- time_op = 1;
- Microwave_1.DecreaseTime(time_op);
- break;
- case '5':
- time_op = 1;
- Microwave_1.IncreaseTime(time_op);
- break;
- case '6':
- time_op = 2;
- Microwave_1.DecreaseTime(time_op);
- break;
- case '7':
- time_op = 2;
- Microwave_1.IncreaseTime(time_op);
- break;
- case '9':
- Microwave_1.TM_ON();
- break;
- case '`':
- case '~':
- case 'Ё':
- case 'ё':
- Microwave_1.Info_ON_OFF();
- break;
- case '0':
- Environment.Exit(0);
- break;
- case ' ':
- {
- Microwave_1.TM_ON();
- break;
- }
- }
- Microwave_1.Print();
- }
- }
- public void TM()
- {
- Console.WriteLine("Hello!");
- }
- }
- public enum Modes
- {
- MICROWAVE, OVEN, DEFROSTING
- }
- class Microwave
- {
- private string m_brand = "no_name";
- private string m_model = "no_name";
- private bool m_state = false;
- private static bool m_tm = false;
- private bool m_info = false;
- private Modes mode = Modes.MICROWAVE;
- private int temperature = 0, power = 300;
- private double weight = 0.1;
- private static int time = 15;
- public Microwave(string brand, string model)
- {
- if (brand.Length <= 15)
- m_brand = brand;
- m_model = model;
- }
- public Microwave(Modes startMode)
- {
- mode = startMode;
- }
- public void SwitchON_OFF()
- {
- if(m_state == false) m_state = true;
- else m_state = false;
- }
- public void Info_ON_OFF()
- {
- if (m_info == false) m_info = true;
- else m_info = false;
- }
- public void TM_OFF()
- {
- m_tm = false;
- }
- public void TM_ON()
- {
- m_tm = true;
- }
- public void NextMode()
- {
- if (m_state && mode != Modes.DEFROSTING)
- {
- mode++;
- }
- }
- public void PreviousMode()
- {
- if (m_state && mode != Modes.MICROWAVE)
- {
- mode--;
- }
- }
- public void IncreasePower(int op)
- {
- if (m_state && power != 700)
- {
- if (op == 2) power += 100;
- else power += 25;
- }
- }
- public void DecreasePower(int op)
- {
- if (m_state && power != 300)
- {
- if (op == 2) power -= 100;
- else power -= 25;
- }
- }
- public void IncreaseTemperature(int op)
- {
- if (m_state && temperature != 250)
- {
- if (op == 2) temperature += 30;
- else temperature += 10;
- }
- }
- public void DecreaseTemperature(int op)
- {
- if (m_state && temperature != 0)
- {
- if (op == 2) temperature -= 30;
- else temperature -= 10;
- }
- }
- public void IncreaseWeight(int op)
- {
- if (m_state && weight < 2.5)
- {
- if (op == 2)
- {
- weight += 0.25;
- time += 300;
- }
- else
- {
- weight += 0.1;
- time += 120;
- }
- }
- }
- public void DecreaseWeight(int op)
- {
- if (m_state && weight > 0.1)
- {
- if (op == 2)
- {
- weight -= 0.25;
- time -= 300;
- }
- else
- {
- weight -= 0.1;
- time -= 120;
- }
- }
- }
- public void IncreaseTime(int op)
- {
- if (m_state && time < 10800)
- {
- if (op == 2) time += 300;
- else time += 15;
- }
- }
- public void DecreaseTime(int op)
- {
- if (m_state && time > 0)
- {
- if (op == 2) time -= 300;
- else time -= 15;
- }
- }
- public static void timer_func()
- {
- int num = 0;
- // устанавливаем метод обратного вызова
- TimerCallback tm = new TimerCallback(Count);
- // создаем таймер
- Timer timer = new Timer(tm, num, 0, 1000);
- }
- public static void Count(object obj)
- {
- // Console.Clear();
- Console.ForegroundColor = ConsoleColor.White;
- if (time >= 0)
- {
- Console.Clear();
- timer_print();
- time--;
- }
- else Console.ReadLine();
- }
- public static void timer_print()
- {
- Console.ForegroundColor = ConsoleColor.White;
- if (time > 3599 && time < 10800)
- {
- Console.Write("{0}:", time / 3600);
- }
- if (time % 3600 > 59 && time % 3600 < 3600)
- {
- if (time % 3600 < 600) Console.Write("0{0}:", (time % 3600) / 60);
- else Console.Write("{0}:", (time % 3600) / 60);
- }
- else Console.Write("00:");
- if ((time % 3600) % 60 < 10) Console.Write("0{0}", (time % 3600) % 60);
- else Console.Write("{0}", (time % 3600) % 60);
- Console.ForegroundColor = ConsoleColor.Gray;
- if (!m_tm) Console.Write("\t\t\t\t\t\t[4]-[5] - Увеличить/Уменьшить время");
- else Console.WriteLine("");
- }
- public void Print()
- {
- Program program_1 = new Program();
- program_1.TM();
- Console.Clear();
- // изменение цвета текста
- Console.ForegroundColor = ConsoleColor.Gray;
- Console.Write(" Микроволновая печь: ");
- Console.ForegroundColor = ConsoleColor.White;
- Console.Write(m_brand + " " + m_model);
- if (m_state)
- {
- Console.ForegroundColor = ConsoleColor.Gray;
- Console.Write("\t\t\t [~] - Допольнительная информация");
- }
- Console.WriteLine("\n");
- if (m_state)
- {
- Console.Title = m_brand + " " + m_model + " - Включено";
- Console.ForegroundColor = ConsoleColor.Gray;
- Console.Write(" Состояние:");
- Console.ForegroundColor = ConsoleColor.Green;
- Console.Write(" включена");
- Console.ForegroundColor = ConsoleColor.Gray;
- Console.WriteLine("\t\t\t\t\t [1] - Включить/Выключить\n");
- Console.ForegroundColor = ConsoleColor.Gray;
- Console.Write(" Режим: ");
- switch (mode)
- {
- case Modes.MICROWAVE:
- Console.ForegroundColor = ConsoleColor.Yellow;
- Console.Write("СВЧ ");
- break;
- case Modes.OVEN:
- Console.ForegroundColor = ConsoleColor.Red;
- Console.Write("Духовка ");
- break;
- case Modes.DEFROSTING:
- Console.ForegroundColor = ConsoleColor.Cyan;
- Console.Write("Разморозка");
- break;
- default:
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine(mode);
- break;
- }
- Console.ForegroundColor = ConsoleColor.Gray;
- Console.WriteLine("\t\t\t\t\t[2]-[3] - Предыдущий/Следующий режим");
- Console.ForegroundColor = ConsoleColor.Gray;
- if (mode == Modes.MICROWAVE)
- {
- Console.Write(" Мощность: ");
- Console.ForegroundColor = ConsoleColor.White;
- Console.Write("{0}", power);
- Console.ForegroundColor = ConsoleColor.Gray;
- Console.Write(" W");
- Console.ForegroundColor = ConsoleColor.Gray;
- Console.Write("\t\t\t\t\t[Q]-[W] - Уменьшить/Увеличить мощность");
- if (m_info)
- {
- Console.ForegroundColor = ConsoleColor.DarkGray;
- Console.WriteLine(" 25 W");
- Console.ForegroundColor = ConsoleColor.DarkYellow;
- Console.Write("\t\t\t\t\t\t\t[E]-[R]\t\t\t\t\t 100 W ");
- }
- else Console.WriteLine("");
- Console.ForegroundColor = ConsoleColor.Gray;
- }
- if (mode == Modes.OVEN)
- {
- Console.Write(" Температура: ");
- Console.ForegroundColor = ConsoleColor.White;
- Console.Write("{0}", temperature);
- Console.ForegroundColor = ConsoleColor.Gray;
- Console.Write("*C");
- Console.ForegroundColor = ConsoleColor.Gray;
- Console.Write("\t\t\t\t\t[E]-[R] - Уменьшить/Увеличить температуру ");
- if (m_info)
- {
- Console.ForegroundColor = ConsoleColor.DarkGray;
- Console.WriteLine(" 10*C");
- Console.ForegroundColor = ConsoleColor.DarkRed;
- Console.Write("\t\t\t\t\t\t\t[D]-[F]\t\t\t\t\t 30*C ");
- }
- else Console.WriteLine("");
- Console.ForegroundColor = ConsoleColor.Gray;
- }
- if (mode == Modes.DEFROSTING)
- {
- Console.Write(" Вес: ");
- Console.ForegroundColor = ConsoleColor.White;
- Console.Write("{0}", weight);
- Console.ForegroundColor = ConsoleColor.Gray;
- Console.Write(" Kg");
- Console.ForegroundColor = ConsoleColor.Gray;
- Console.Write("\t\t\t\t\t\t[A]-[S] - Уменьшить/Увеличить вес");
- if (m_info)
- {
- Console.ForegroundColor = ConsoleColor.DarkGray;
- Console.WriteLine("\t 100 g ");
- Console.ForegroundColor = ConsoleColor.DarkCyan;
- Console.Write("\t\t\t\t\t\t\t[C]-[V]\t\t\t\t\t 250 g ");
- }
- else Console.WriteLine("");
- Console.ForegroundColor = ConsoleColor.Gray;
- }
- Console.Write("\n Таймер: ");
- if (m_tm && time > 0)
- {
- Console.Clear();
- timer_func();
- }
- else
- {
- m_tm = false;
- timer_print();
- if (m_info)
- {
- Console.ForegroundColor = ConsoleColor.DarkGray;
- Console.WriteLine("\t 15 sec ");
- Console.Write("\t\t\t\t\t\t\t[6]-[7]\t\t\t\t\t 1 min ");
- }
- else Console.WriteLine("");
- Console.ForegroundColor = ConsoleColor.Gray;
- Console.WriteLine("\n\t\t\t\t\t\t\t[Space] - Пуск");
- }
- Console.ForegroundColor = ConsoleColor.Gray;
- if (m_info&&!m_tm)
- {
- Console.ForegroundColor = ConsoleColor.DarkGray;
- Console.WriteLine("\n\t\t\t\t\t\t\t [0] - Завершение программы");
- Console.ForegroundColor = ConsoleColor.Gray;
- }
- }
- else
- {
- Console.Title = m_brand + " " + m_model + " - Отключено";
- Console.ForegroundColor = ConsoleColor.Gray;
- Console.Write(" Состояние: ");
- Console.ForegroundColor = ConsoleColor.Red;
- Console.Write("выключена ");
- Console.ForegroundColor = ConsoleColor.Gray;
- Console.WriteLine("\t\t\t\t\t [1] - Включить/Выключить\n");
- Console.ForegroundColor = ConsoleColor.Gray;
- Console.WriteLine("");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement