Okay, so here is the code for the class Movie
that we have written thus far. Now, bear in mind, that
you may have to go into full-screen mode in order
to see all of the details here properly. And I'm really
curious to figure out what happens behind the scenes when
I run this line of code. What happens when I create
an instance called toy_story by providing these four pieces of
information or arguments. These pieces of information are the name of
the movie, its story line, the link to its poster,
and the link to its YouTube URL. Now clearly, the
last two of these are not really links or URLs
just yet. They are English phrases and I did that because
there wasn't enough space on the screen for me to
add the full links or the URLs to the poster and
the YouTube trailer. So, the first thing that happens when
we learn this line of code is that the init function
gets called. And the init function, you
will recall, is the function we defined inside
class Movie. Self, in that case, is itself
or the instance being created, which is toy_story.
The next argument is movie_title whose value
is Toy Story. Movie_storyline gets the value Toys
come to life. The variable poster_image gets the
right value. And finally, the trailer_youtube variable gets
the correct link. Okay, so far so good. Now, once init gets called and
all of these arguments receive their correct
values, all of the variables that are associated
with the instance toy_story, they get initialized
appropriately and these variables, you may notice,
are title, storyline, poster_image_url and trailer_youtube_url. At
this point, if I try to print out
toy_story.storyline, it prints out the correct value. All right,
now that we know exactly what happens when we create
this instance toy story. Let's go back to our
design and find out what we have to do next.
حسنًا، هذه هي التعليمة البرمجية للفئة Movie
التي كتبناها حتى الآن. والآن، انتبه إلى أنه
قد يتعين عليك الانتقال إلى وضع ملء الشاشة حتى
تتمكن من رؤية كل التفاصيل هنا كما ينبغي. وأنا ينتابني الفضول حقًا
لمعرفة ما يحدث خلف الكواليس
عندما أقوم بتشغيل سطر التعليمة البرمجية هذا. ماذا يحدث عندما أقوم بإنشاء
مثيل اسمه toy_story من خلال إدخال هذه العناصر الأربعة
أو الوسيطات. تلك المعلومات هي
اسم الفيلم، وقصته، والرابط لصورة
ملصق الدعاية، ورابط عنوان URL الخاص بالفيلم على YouTube. والآن، من الواضح
أن آخر وسيطتين ليستا رابطين فعليين أو عنواني URL
حتى الآن. ولكن يبدو وكأنها عبارات إنجليزية، ولقد فعلت ذلك لأنه
لا توجد مساحة كافية على الشاشة كي
أضيف عناوين URL أو الروابط الكاملة إلى صورة ملصق الدعاية
ومقتطفات الدعاية للفيلم على YouTube. إذن، أول شيء يحدث عندما نقوم بتشغيل هذا السطر
من التعليمة البرمجية، هو أنه يتم استدعاء دالة init
ودالة init التي .
ستستدعيها، هي الدالة التي قمنا بتعريفها داخل
الفئة Movie. Self، في هذه
.الحالة، يكون المثيل ذاته الذي يتم إنشاؤه، وهو toy_story
الوسيطة التالية هي movie_title، وقيمتها
هي Toy Story. أما الوسيطة Movie_storyline، فقيمتها هي
ToysCometoLife. يحصل المتغير poster_image على
القيمة الصحيحة أيضًا. وأخيرًا، يحصل المتغير trailer_youtube
على الرابط الصحيح. Okay, so far so good. الآن، بمجرد طلب دالة init وتلقي كل وسيطة من هذه الوسيطات
قيمها الملائمة، يتم تهيئة جميع المتغيرات
المقترنة بالمثيل
toy_story بطريقة صحيحة
:وهذه المتغيرات، كما ترى، هي
،title، وstoryline، وposter_image_url، وtrailer_youtube_url. في هذه المرحلة
،إذا كتبت toy_story.storyline
،فسيُخرج البرنامج القيمة الصحيحة. حسنًا
والآن بما أننا نعرف ما يحدث بالضبط عند
إنشاء المثيل toy_story. فلنعُد إلى
.تصميمنا لنكتشف ما علينا القيام به بعد ذلك
De acuerdo, este es el código para la clase Movie
que hemos escrito hasta ahora. Bien, tengan en cuenta que
puede que tengan que activar el modo de pantalla completa para
para ver todos los detalles adecuadamente. Tengo mucha
curiosidad de descubrir lo que sucede detrás de escenas cuando
ejecuto esta línea de código. Lo que sucede cuando creo
una instancia llamada toy_story proporcionando estos cuatro elementos de
información o valores. Estos elementos de información son el nombre de
la película, su trama, el enlace a su póster
y el enlace a su URL de YouTube. Claramente, los
dos últimos de estos no son realmente enlaces o URLs
todavía. Son frases en inglés e hice eso porque
no había suficiente espacio en la pantalla para que
yo agregara los enlaces completos o las direcciones URL al póster y
el avance de Youtube. Entonces, lo primero que sucede cuando
ejecutamos esta línea de código es que se llama a
la función init. Y la función init,
como recordarán, es la función que definimos dentro
de la clase Movie. Self, en ese caso, es sí misma
o la instancia que se está creando, que es Toy Story
El siguiente argumento es movie_title cuyo valor
es Toy Story. Movie_storyline obtiene el valor
Toys La variable poster_image obtiene
el valor correcto. Y, por último, la variable trailer_youtube obtiene
el enlace correcto. Perfecto.Hasta ahora, todo bien. Bueno, una vez que se llama a init y
todos estos argumentos reciben sus valores
correctos, todas las variables que se asocian
con la instancia toy_story, se inician
de manera correcta y estas variables, pueden darse cuenta,
son título, trama, poster_image_url y trailer_youtube_url. En
este punto, si trato de imprimir
toy_story.storyline, se imprime el valor correcto. Perfecto,
ahora que sabemos exactamente lo que sucede cuando creamos
la instancia toy_story volvamos a nuestro
diseño y averigüemos lo que tenemos que hacer a continuación.
これは前回書いたMovieクラスのコードです
念のためお伝えしますが
すべてのコードを見るためには
全画面表示にするといいでしょう
ところで私はコード行を実行する時に
裏で何が起きているか
とても気になります
なぜ4つの情報や引数を与えると
toy_storyのインスタンスができるのでしょう
情報というのは映画のタイトルやあらすじ
またポスターや予告編へのリンクのことです
お分かりでしょうが
最後の2つはこのままでは機能しません
ここを単なる英語の文にしたのは
ポスターのリンクやYouTubeのURLは
長すぎて画面に全部表示しきれないからです
さてこのコード行を実行すると
最初に__init__関数が呼び出されます
呼び出される__init__関数とは
Movieクラスで定義した関数のことです
そしてselfは作成されるインスタンス自体であり
今回の場合はtoy_storyです
次の引数は「トイ・ストーリー」という
タイトルを表示するmovie_titleです
movie_storylineはあらすじを表示し
poster_image変数がリンク先の画像を表示させ
trailer_youtube変数はリンク先の動画を表示します
ここまではいい感じです
__init__関数が呼び出されると
引数が適切な値を受け取り
インスタンスtoy_storyに関連する変数は
適切に初期化されます
ここでいう変数とは
title、storyline、poster_image_url、
trailer_youtube_urlです
ここでtoy_story.storylineを実行すると
正しい値が表示されます
インスタンスtoy_storyを作る時の
仕組みが分かったところで
デザインに戻って次に進みましょう
Este é o código da classe Movie
que criamos até agora. Lembre-se que
talvez você tenha que passar para o modo de tela inteira
para ver todos os detalhes corretamente. Estou muito
curioso para saber o que acontece nos bastidores quando
executo esta linha de código. o que acontece quando crio
uma instância chamada toy_story fornecendo estas quatro
informações ou argumentos. Essas informações são o nome e
a história do filme, o link para o cartaz
e o link para a URL no YouTube. Obviamente, estes
dois últimos não são realmente links ou URLs
ainda. Eles são frases em inglês. Isso foi necessário porque
não havia espaço suficiente na tela para
adicionar os links ou URLs completos para o cartaz e o
trailer no YouTube. A primeira coisa que acontece quando
aprendemos esta linha de código é que a função init
é chamada. A função init
é a função definida na
classe Movie. Self, nesse caso, é ela mesma ou
a instância sendo criada, ou seja, toy_story.
O próximo argumento é movie_title, cujo valor
é Toy Story. Movie_storyline tem o valor
Toys Come to Life. A variável poster_image recebe
o valor apropriado. Finalmente, a variável trailer_youtube
recebe o link correto. Até aqui, tudo bem. Após a função init ser chamada e
todos esses argumentos receberem os valores
apropriados, todas as variáveis associadas
à instância toy_story são inicializadas
apropriadamente. Como você pode observar, essas variáveis
são title, storyline, poster_image_url e trailer_youtube_url. Neste
ponto, se eu tentar imprimir
toy_story.storyline, o programa imprimirá o valor correto. Agora
que sabemos exatamente o que acontece ao criar
a instância toy_story, vamos voltar ao
projeto e descobrir o que temos que fazer em seguida.
好的 这是我们目前为止编写的
类 Movie 的代码 注意 你
可能得切换到全屏模式才能
清楚地看到所有的详细信息 现在我非常
好奇 当我运行这行代码时
后台会发生什么 我提供四条信息或自变量
创建 toy_story 的实例时
会发生什么?这些信息是电影的名称、
它的故事情节、海报的链接
和 YouTube URL 的链接 显然 后面
这两个并非真正的链接或 URL
链接 它们只是英语短语 我之所以这么做
是因为屏幕上没有足够的空间来
添加海报和 YouTube 预告片的
完整链接 我们运行这行代码时
发生的第一件事就是 init 函数
会被调用 你应该记得 init 函数
是我们在类 Movie 中
定义的一个函数 在这个情况下 self 指的是
类自己或创建的实例 即 toy_story
下一个自变量是 movie_title 它的值
是 Toy Story Movie_storyline 的值是
玩具复活了 变量 poster_imag 也获得了
正确的值 最后 trailer_youtube 变量获得了
正确的链接 所以 目前一切进展顺利 现在 一旦 init 被调用 以及
所有的自变量获得正确的
值 实例 toy_story 相关联的所有的
变量也会被适当地初始化 你
应该注意到了 这些
title、storyline、poster_image_url 和 trailer_youtube_url 现在
如果我尝试打印
toy_story.storyline 它会打印出正确的值 好的
现在我们知道在创建实例 toy story 时
到底会发生什么 然后我们返回
设计 看看接下来应该做什么
好的, 這是我們目前為止撰寫的Movie類別程式碼。
現在請注意,
你可能得切換到全螢幕模式才能清楚地看到
所有的詳細訊息。現在我非常好奇,
當我執行這行程式碼時,在後端程式會發生什麼
當我提供四條訊息或參數,傳遞給我建立
的名稱為toy_story的實例,會發生什麼?
這些訊息是電影的名稱、
它的故事情節、海報的連結
和 YouTube URL 的連結,顯然後面
這兩個並非真正的連結或URL
它們只是英語短句, 我之所以這麼做
是因為螢幕上沒有足夠的空間來
添加海報和 YouTube 預告片的完整連結,
當我們執行這行程式碼時
發生的第一件事就是 init 函數會被呼叫
你應該記得 init 函數
是我們在Movie類別中定義的一個函數
在這個情況下 self 指的是
類別它自己或建立的實例,即 toy_story
下一個參數是 movie_title 它的值是玩具總動員
, Movie_storyline 的值是玩具復活了,
變數 poster_imag 也獲得了
正確的值。最後 trailer_youtube 變數獲得了
正確的連結, 所以,目前一切進展順利,現在 一旦 init 被呼叫,
所有的參數獲得正確的值
toy_story 實例相關聯的所有的
變數也會被適當地初始化,
你應該注意到了,
這些title、storyline、poster_image_url 和 trailer_youtube_url
現在如果我嘗試印出來
toy_story.storyline 它會輸出正確的值,好的
現在我們知道在建立 toy story實例時
到底會發生什麼。然後我們返回設計
看看接下來應該做什麼。