Ejemplo n.º 1
0
        /// <summary>
        /// Implemente uma classe Televisão que tenha métodos para ligar e
        /// desligar, aumentar ou diminuir o volume(com mínimo de 0 e máximo de 100) e
        /// subir ou baixar o canal(entre 1 e 83).
        /// </summary>
        public void Ex09_08_3()
        {
            Television television = new Television();
            string     op         = "";
            int        s;

            while (op != "S")
            {
                Console.Clear();
                Console.WriteLine("on or ON - Turn on the television.");
                Console.WriteLine("off or OFF - Turn off the television.");
                Console.WriteLine("ic or IC - Increase the channel.");
                Console.WriteLine("dc or DC - Decrease the channel.");
                Console.WriteLine("iv or IV - Increase the volume.");
                Console.WriteLine("dv or DV - Decrease the volume.");
                Console.WriteLine("s or S - Exit.");
                Console.WriteLine();
                Console.WriteLine(television);
                Console.WriteLine();
                Console.Write("Option: ");
                op = Console.ReadLine().ToUpper();
                switch (op)
                {
                case "ON":
                    television.TurnOn();
                    break;

                case "OFF":
                    television.TurnOff();
                    break;

                case "IC":
                    television.IncreaseChannel();
                    break;

                case "DC":
                    television.DecreaseChannel();
                    break;

                case "IV":
                    television.IncreaseVolume();
                    break;

                case "DV":
                    television.DecreaseVolume();
                    break;

                case "S":
                    break;

                default:
                    Console.WriteLine("Invalid Option.");
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            //Variable to accept user input
            int station;

            //Declare and instatiate a television object
            Television bigScreen = new Television("Toshiba", 55);

            //Turn the power on
            bigScreen.Power();

            //Display the state of the television
            Console.WriteLine(bigScreen.ToString());

            //Prompt the user for input and store it in the station variable
            Console.WriteLine("What channel do you want? ");
            station = int.Parse(Console.ReadLine());

            //Change the channel on the television
            bigScreen.SetChannel(station);

            //Increase the volumne of the television
            bigScreen.IncreaseVolume();

            //Display the current channel and volumne
            Console.WriteLine("Channel: " + bigScreen.GetChannel() + " Volume: " + bigScreen.GetVolume());

            Console.WriteLine("Too loud!  Lowering the volume.");

            //Decrease the volume
            for (int x = 0; x < 6; x++)
            {
                bigScreen.DecreaseVolume();
            }

            //Display the current channel and volumne
            Console.WriteLine("Channel: " + bigScreen.GetChannel() + " Volume: " + bigScreen.GetVolume());

            //create blank line
            Console.WriteLine();

            //HERE IS WHERE YOU DO TASK 5

            Console.ReadKey();
        }