English subtitles

← 06-15 Playing Movie Trailer

06-15 Playing Movie Trailer

Get Embed Code
7 Languages

Showing Revision 6 created 05/07/2015 by Udacity Robot.

  1. So, here is my code for the class movie, and behind it, is hidden
  2. the other programming file, where we have
  3. defined multiple instances of the class movie, namely
  4. Toy Story and Avatar. So, what I will do, is go back to my
  5. code for the class movie, and define
  6. a new function or method there called, show_trailer.
  7. Now, each instance method, whether it be init
  8. or show_trailer takes the first argument as, self. So
  9. I will add that. All, show_trailer has to do,
  10. is open the web browser, with the correct URL.
  11. And the link or the URL, is stored in
  12. the instance variable. Trailer Youtube URL. The way to
  13. access this instance variable, is through the self keyword.
  14. One last thing I need to make this code
  15. work, is to import web browser. [SOUND]
  16. There, let me go ahead and save this file. Now that we have defined
  17. the method, show_trailer. The next thing for us to do, is to call this method,
  18. using our other programming file. So I will go there, and here, I already
  19. have the instance or object called, Avatar.
  20. [SOUND]. So I will use it, [SOUND] Avatar,
  21. to call the show_trailer method. [SOUND] I'm
  22. going to go ahead and save this file.
  23. And then I will run it.
  24. [MUSIC]
  25. Wow, that was outstanding.