Beispiel #1
0
        static void Main(string[] args)
        {
            Radio radio = new Radio();

            Console.WriteLine("0. To quit. \n1. For power switch. \n2. For frequency set. \n3. For Volume set. \n4. To display this message again. \n5. Displays the status.");
            Console.WriteLine(radio.Info());
            Console.Write("Make a selection > ");
            string line1 = Console.ReadLine();
            int    Pick  = int.Parse(line1);

            while (Pick != 0)
            {
                switch (Pick)
                {
                case 0:
                    break;

                case 1:
                    radio.PowerSwitch();
                    break;

                case 2:
                    Console.Write("Give a new frequency (2000.0 - 26000.0) >");
                    string lineFreq = Console.ReadLine();
                    radio.Frequency = double.Parse(lineFreq);
                    break;

                case 3:
                    Console.Write("Give a new volume (0 - 9) >");
                    string lineVol = Console.ReadLine();
                    radio.Volume = int.Parse(lineVol);
                    break;

                case 4:
                    Console.WriteLine("0. To quit. \n1. For power switch. \n2. For frequency set. \n3. For Volume set. \n4. To display this message again. \n5. Displays the status.");
                    break;

                case 5:
                    Console.WriteLine(radio.Info());
                    break;
                }

                Console.Write("Make a selection > ");
                line1 = Console.ReadLine();
                Pick  = int.Parse(line1);
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Radio  radio1 = new Radio();
            int    input1;
            double input2;

            while (true)
            {
                Console.WriteLine("Radio volume is set to: " + radio1.Volume);
                Console.WriteLine("Give a new volume value (0 - 9): ");
                input1 = int.Parse(Console.ReadLine());

                radio1.Volume = input1;

                Console.WriteLine("Radio frequency is set to: " + radio1.Frequency);
                Console.WriteLine("Set a new frequency (2000.0 - 26000.0): ");
                input2 = double.Parse(Console.ReadLine());

                radio1.Frequency = input2;
            }
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            Radio sony = new Radio();

            sony.Power = true;

            sony.Volume = 5;

            sony.Frequency = 2400.4;

            sony.Volume = -4;

            sony.Frequency = 20.6;

            sony.Volume = 20;

            sony.Frequency = 801320.5434;

            sony.Volume = 8;

            sony.Frequency = 2670.34;

            sony.Power = false;
        }