Пример #1
0
    static void Main()
    {
        Television tv = new Television();

        if (tv.IsOn() == false)
        {
            tv.TurnOn();
        }

        tv.ChangeChannel(3);

        tv.IncreaseVolume();
        tv.IncreaseVolume();
        tv.IncreaseVolume();
        tv.IncreaseVolume();

        tv.TurnOff();
    }
Пример #2
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;
                }
            }
        }
Пример #3
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();
        }
Пример #4
0
    static void Main()
    {
        Television tv = new Television();

        if (tv.IsOn() == false)
        {
            tv.TurnOn();
        }

        tv.ChangeChannel(3);

        tv.IncreaseVolume();
        tv.IncreaseVolume();
        tv.IncreaseVolume();
        tv.IncreaseVolume();

        tv.TurnOff();
    }
Пример #5
0
        public override void Execute()
        {
            var television = new Television();

            Assert.IsType <TelevisionOffState>(television.State);
            Assert.False(television.Powered);
            Assert.Null(television.Volume);
            Assert.Null(television.Muted);

            television.LowerVolume();
            // Nothing should changes when the television is off.
            Assert.IsType <TelevisionOffState>(television.State);
            Assert.False(television.Powered);
            Assert.Null(television.Volume);
            Assert.Null(television.Muted);

            television.IncreaseVolume();
            Assert.IsType <TelevisionOffState>(television.State);
            Assert.False(television.Powered);
            Assert.Null(television.Volume);
            Assert.Null(television.Muted);

            television.ToggleMute();
            Assert.IsType <TelevisionOffState>(television.State);
            Assert.False(television.Powered);
            Assert.Null(television.Volume);
            Assert.Null(television.Muted);


            // Let's power it up.
            television.TogglePower();
            Assert.IsType <TelevisionOnState>(television.State);
            Assert.True(television.Powered);
            Assert.Equal(2, television.Volume);
            Assert.False(television.Muted);

            television.LowerVolume();
            television.LowerVolume();
            television.LowerVolume();
            Assert.IsType <TelevisionOnState>(television.State);
            Assert.True(television.Powered);
            Assert.Equal(0, television.Volume);
            Assert.False(television.Muted);

            television.IncreaseVolume();
            television.IncreaseVolume();
            television.IncreaseVolume();
            Assert.IsType <TelevisionOnState>(television.State);
            Assert.True(television.Powered);
            Assert.Equal(3, television.Volume);
            Assert.False(television.Muted);

            television.ToggleMute();
            Assert.IsType <TelevisionMutedState>(television.State);
            Assert.True(television.Powered);
            Assert.Equal(3, television.Volume);
            Assert.True(television.Muted);

            television.IncreaseVolume();
            Assert.IsType <TelevisionOnState>(television.State);
            Assert.True(television.Powered);
            Assert.Equal(4, television.Volume);
            Assert.False(television.Muted);

            television.ToggleMute();
            television.ToggleMute();
            Assert.IsType <TelevisionOnState>(television.State);
            Assert.True(television.Powered);
            Assert.Equal(4, television.Volume);
            Assert.False(television.Muted);

            television.TogglePower();
            Assert.IsType <TelevisionOffState>(television.State);
            Assert.False(television.Powered);
            Assert.Null(television.Volume);
            Assert.Null(television.Muted);
        }