Exemplo n.º 1
0
 //POWER OFF
 private void PowerOffButton_Click(object sender, RoutedEventArgs e)
 {
     radio.PowerOff();
     RadioState.Text = $"{radio.PowerOff()}";
     Player.Stop();
     RadioStation.Text = "FM Radio";
     radio.Write(); //SERIALIZE
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Radio radio = new Radio();
            radio.PowerOn();
            radio.PrintData();

            do
            {
                Console.WriteLine("* Choose action *");
                Console.WriteLine("1. Adjust Volume ");
                Console.WriteLine("2. Adjust Frequency ");
                Console.WriteLine("3. Power off ");

                int action = int.Parse(Console.ReadLine());

                switch (action)
                {
                    case 1:
                        radio.AdjustVolume();
                        break;

                    case 2:
                        radio.AdjustFrequency();
                        break;

                    case 3:
                        radio.PowerOff();
                        break;

                    default:
                        Console.WriteLine("Error! ");
                        break;
                }

                radio.PrintData();               

            } while (radio.Power != false);

            Console.ReadLine();

        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            Radio radio = new Radio();

            radio.PowerOff();
            while (true)
            {
                Console.WriteLine("Change channel 0");
                Console.WriteLine("Change volume  1");
                Console.WriteLine("Power on  2");
                Console.WriteLine("Power off 3");
                Console.WriteLine("Quit 4");
                bool result = int.TryParse(Console.ReadLine(), out int number);
                if (result)
                {
                    switch (number)
                    {
                    case 0:
                    {
                        Console.Write("Set channel 2000.0 - 26000.0: ");
                        bool result2 = double.TryParse(Console.ReadLine(), out double number2);
                        if (result2)
                        {
                            radio.Channel = number2;
                        }
                        else
                        {
                            continue;
                        }
                        continue;
                    }

                    case 1:
                    {
                        Console.Write("Set volume 1 - 10: ");
                        bool result2 = int.TryParse(Console.ReadLine(), out int number2);
                        if (result2)
                        {
                            radio.Volume = number2;
                        }
                        else
                        {
                            continue;
                        }
                        continue;
                    }

                    case 2:
                    {
                        Console.Write("Set power on? yes/no: ");
                        string input = Console.ReadLine();
                        if (input == "yes")
                        {
                            radio.PowerOn();
                        }
                        else
                        {
                            continue;
                        }
                        continue;
                    }

                    case 3:
                    {
                        Console.Write("Set power off? yes/no: ");
                        string input = Console.ReadLine();
                        if (input == "yes")
                        {
                            radio.PowerOff();
                        }
                        else
                        {
                            continue;
                        }
                        continue;
                    }

                    case 4:
                        break;
                    }
                }
                break;
            }
        }