Return to Video

06-15 Playing Movie Trailer

  • 0:00 - 0:04
    So, here is my code for the class movie, and behind it, is hidden
  • 0:04 - 0:06
    the other programming file, where we have
  • 0:06 - 0:09
    defined multiple instances of the class movie, namely
  • 0:09 - 0:13
    Toy Story and Avatar. So, what I will do, is go back to my
  • 0:13 - 0:15
    code for the class movie, and define
  • 0:15 - 0:19
    a new function or method there called, show_trailer.
  • 0:22 - 0:25
    Now, each instance method, whether it be init
  • 0:25 - 0:29
    or show_trailer takes the first argument as, self. So
  • 0:29 - 0:32
    I will add that. All, show_trailer has to do,
  • 0:32 - 0:35
    is open the web browser, with the correct URL.
  • 0:35 - 0:38
    And the link or the URL, is stored in
  • 0:38 - 0:42
    the instance variable. Trailer Youtube URL. The way to
  • 0:42 - 0:45
    access this instance variable, is through the self keyword.
  • 0:45 - 0:47
    One last thing I need to make this code
  • 0:47 - 0:53
    work, is to import web browser. [SOUND]
  • 0:53 - 0:57
    There, let me go ahead and save this file. Now that we have defined
  • 0:57 - 1:02
    the method, show_trailer. The next thing for us to do, is to call this method,
  • 1:02 - 1:06
    using our other programming file. So I will go there, and here, I already
  • 1:06 - 1:08
    have the instance or object called, Avatar.
  • 1:08 - 1:12
    [SOUND]. So I will use it, [SOUND] Avatar,
  • 1:12 - 1:15
    to call the show_trailer method. [SOUND] I'm
  • 1:15 - 1:16
    going to go ahead and save this file.
  • 1:22 - 1:23
    And then I will run it.
  • 1:23 - 1:26
    [MUSIC]
  • 1:26 - 1:33
    Wow, that was outstanding.
Title:
06-15 Playing Movie Trailer
Description:

06-15 Playing Movie Trailer

more » « less
Video Language:
English
Team:
Udacity
Project:
UD036 - OOP
Duration:
01:34

English subtitles

Revisions Compare revisions