private static void Main(string[] args) { var telephone = new Telephone(); Console.WriteLine(telephone.Name); telephone.OutboundCall("+1 234 567"); Console.WriteLine("Am I a Telephone? {0}", telephone is Telephone); Console.WriteLine("Am I a MP3? {0}", telephone is MediaPlayer3); Console.WriteLine("Am I a Smartphone? {0}", telephone is Smartphone); Console.WriteLine("Do I Have Telephone Capabilities? {0}", telephone is ITelephone); Console.WriteLine("Do I Have MP3 Capabilities? {0}", telephone is IMediaPlayer3); Console.WriteLine(); var mp3 = new MediaPlayer3(); Console.WriteLine(mp3.Name); mp3.PlaySong("Lalala"); Console.WriteLine("Am I a Telephone? {0}", mp3 is Telephone); Console.WriteLine("Am I a MP3? {0}", mp3 is MediaPlayer3); Console.WriteLine("Am I a Smartphone? {0}", mp3 is Smartphone); Console.WriteLine("Do I Have Telephone Capabilities? {0}", mp3 is ITelephone); Console.WriteLine("Do I Have MP3 Capabilities? {0}", mp3 is IMediaPlayer3); Console.WriteLine(); var smartphone = new Smartphone(); Console.WriteLine(smartphone.Name); smartphone.OutboundCall("+1 234 567"); smartphone.PlaySong("Lalala"); Console.WriteLine("Am I a Telephone? {0}", smartphone is Telephone); Console.WriteLine("Am I a MP3? {0}", smartphone is MediaPlayer3); Console.WriteLine("Am I a Smartphone? {0}", smartphone is Smartphone); Console.WriteLine("Do I Have Telephone Capabilities? {0}", smartphone is ITelephone); Console.WriteLine("Do I Have MP3 Capabilities? {0}", smartphone is IMediaPlayer3); Console.ReadKey(); }
public void Goin() { BackExit.setBack(Goin); sNum = 0; fNum = 0; CD.setMainUI(this); time.start(); successNum.Text = "0"; failedNum.Text = "0"; status.Text = "空闲"; hasPath1 = false; hasPath2 = false; hasPath3 = false; string path1 = CD.getBasePath() + "Media\\openBox.mp4"; string path2 = CD.getBasePath() + "Media\\addCar.mp4"; string path3 = CD.getBasePath() + "Media\\closeBox.mp4"; if (File.Exists(path1)) { MediaPlayer1.Source = new Uri(path1); MediaPlayer1.Play(); hasPath1 = true; } else { MessageBox.Show("文件丢失:" + path1); } if (File.Exists(path2)) { MediaPlayer2.Source = new Uri(path2); MediaPlayer2.Play(); hasPath2 = true; } else { MessageBox.Show("文件丢失:" + path2); } if (File.Exists(path3)) { MediaPlayer3.Source = new Uri(path3); MediaPlayer3.Play(); hasPath3 = true; } else { MessageBox.Show("文件丢失:" + path3); } }
private void WhenExit() { if (hasPath1) { MediaPlayer1.Stop(); } if (hasPath2) { MediaPlayer2.Stop(); } if (hasPath3) { MediaPlayer3.Stop(); } }
public Smartphone() { telephone = new Telephone(); mp3 = new MediaPlayer3(); }