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(); }
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(); }
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(); }
public void Undo() { device.VolumeDown(); }
public void Execute() { device.VolumeDown(); }
public void VoDown() { device.VolumeDown(); }
public void VolDecrement() { device.VolumeDown(); }