Пример #1
0
        static void Main(string[] args)
        {
            Vehicle ford = new Vehicle("Ford", 4, 80);

            if (ford is IDrivable)
            {
                ford.Move();
                ford.Stop();
            }
            else
            {
                Console.WriteLine($"The {ford.Brand} cannot be driven");
            }

            // Pick up Remote
            IElectronicDevice TV = TVRemote.GetDevice();

            // Next create power button
            PowerButton powerButton = new PowerButton(TV);

            // Turn TV On and Off
            powerButton.Execute();

            TV.VolumeUp();
            TV.VolumeUp();
            TV.VolumeUp();
            TV.VolumeUp();
            TV.VolumeDown();
            TV.VolumeDown();

            powerButton.Undo();

            Console.ReadLine();
        }
Пример #2
0
        static void Main(string[] args)
        {
            Vehicle buick = new Vehicle("Buick", 4, 180);
            Vehicle dacia = new Vehicle("Dacia");

            if (buick is IDrivable)
            {
                buick.Move();
                buick.Stop();
            }
            else
            {
                Console.WriteLine("The {0} can't be driven.", buick.Brand);
            }

            if (dacia is IDrivable)
            {
                dacia.Move();
                dacia.Stop();
            }
            else
            {
                Console.WriteLine("The {0} can't be driven.", dacia.Brand);
            }

            IElectronicDevice TV = TVRemote.GetDevice();

            PowerButtoon powBut = new PowerButtoon(TV);

            powBut.Execute();
            TV.VolumeUp();
            TV.VolumeDown();
            powBut.Undo();
        }
Пример #3
0
        static void Main(string[] args)
        {
            //String name = Console.ReadLine();
            //    Console.WriteLine("Hi " + name + ". Please enter the hours of sleep");
            //    int number = int.Parse(Console.ReadLine());
            //    if (number > 10)
            //    {
            //        Console.WriteLine("You are getting enough sleep. Thank you");
            //    }
            //    else
            //    {
            //        Console.WriteLine("You need enough sleep biko");
            //    }
            Gradebook gr = new ThrowAwayGradeBook();//bcos I inherited from the class Gradebook

            //delegates can call multiple methods and also u can multi cast or simply just add delegates by using +=
            // gr.Namechanged = new NameChangedDelegate(OnNameChanged);
            gr.Namechanged += new NameChangedDelegate(OnNameChanged);
            gr.Namechanged += new NameChangedDelegate(OnNameChanged2);
            gr.Name         = "Chidi's book";
            gr.Name         = "My new book";
            gr.AddGrade(23);
            gr.AddGrade(89);
            gr.AddGrade(45);
            GradeStatistics stats = gr.ComputeStatistics();

            Console.WriteLine("Average score is: " + stats.AverageGrade);
            Console.WriteLine("Lowest score is: " + stats.lowestGrade);
            Console.WriteLine("highest score is: " + stats.HighestGrade);
            using (StreamWriter output = File.CreateText(@"D:\grade.txt"))
            {
                gr.WriteGrades(output);
            }
            Vehicle mycar = new Vehicle("Benz", 4, 160);

            if (mycar is IDrivable)
            {
                mycar.Move();
                mycar.Stop();
            }
            else
            {
                Console.WriteLine($"The brand '{mycar.Brand}' cant be driven");
            }

            IElectronicDevice TV  = TVRemote.GetDevice();
            PowerButton       pwr = new PowerButton(TV);

            pwr.Execute();
            TV.Off();
            TV.VolumeUp();
            TV.VolumeDown();
        }
Пример #4
0
        private static void Sample2()
        {
            // We are now modeling the act of
            // picking up a remote, aiming it
            // at the TV, clicking the power
            // button and then watching as
            // the TV turns on and off

            // Pick up the TV remote
            IElectronicDevice TV = TvRemote.GetDevice();

            // Create the power button
            PowerButton powBut = new PowerButton(TV);

            // Turn the TV on and off with each
            // press
            powBut.Execute();
            TV.VolumeUp();
            powBut.Undo();
        }
Пример #5
0
 public void Execute()
 {
     device.VolumeUp();
 }
Пример #6
0
 public void Execute()
 {
     theDevice.VolumeUp();
 }
Пример #7
0
 public void Execute()
 {
     device.On();
     device.VolumeUp();
     //device.VolumeDown();
 }
Пример #8
0
 public void VoUp()
 {
     device.VolumeUp();
 }
Пример #9
0
 public void Undo()
 {
     theDevice.VolumeUp();
 }
Пример #10
0
 public void Undo()
 {
     device.VolumeUp();
 }
 // HOMEWORK
 public void VolIncrement()
 {
     device.VolumeUp();
 }