Here is the first question, I just copied it from a previous program. Here's
the second question. Notice the first one is a, plain old question, the second
one is a choice question. I'm passing both of them to the presentQuestion
method. That's just one of those methods, it's down here, and its parameter has
type Question. So it's okay to pass a choice question into a question
parameter. You can always convert from the subclass to the super class.
Aquí está la primera pregunta, sólo la copié de un programa previo. Aquí está
la segunda pregunta. Fíjate en que la primera es una simple y anticuada pregunta y que la segunda
es una pregunta de opción. Estoy pasando ambas al método
presentQuestion. Ese es sólo uno de estos métodos, está aquí abajo, y su parámetro tiene un
tipo Pregunta. Así que está bien pasar una pregunta de opción a un parámetro de
pregunta. Siempre puedes convertir de la subclase a la superclase.
Voici la première question que j'ai
copiée d'un programme précédent.
Voici la deuxième question.
Remarquez que la première est
une simple question,
la seconde est une question de choix.
Je passe les deux à la méthode
presentQuestion.
C'est une de ces méthodes, c'est ici,
et son paramètre a le type Question.
On peut donc passer une question
de choix dans un paramètre de question.
Vous pouvez toujours convertir
de la sous-classe à la superclasse.
最初の問題は以前のプログラムからのコピーで
以前の簡単なQuestionオブジェクトです
2つ目の問題は
ChoiceQuestionオブジェクトで
両方ともpresentQuestionメソッドに渡しています
そのメソッドはこの中にあって
パラメータはQuestion型なので
Question型のパラメータに
ChoiceQuestionオブジェクトを渡せます
サブクラスからスーパークラスへの変換は
常に可能です
이게 첫 번째 질문입니다. 저는 전에 있던 프로그램에서 복사했습니다. 여기에
두 번째 질문이 있습니다. 첫 번째 질문은 보통 질문이고 두 번째 질문은
선택형 질문입니다. 이 두 질문들을 presentQuestion에 보내고
있습니다. 이 메소드는 하나만 호출하고 있습니다. 매개변수는
Question 자료형을 가지고 있습니다. 그래서 ChoiceQuestion을 Question 매개변수에
넣어도 됩니다. 여러분은 항상 서브 클래스에서 슈퍼 클래스로 변환할 수 있습니다.
Đây là câu hỏi đầu tiên, tôi đã copy nó từ chương trình trước.
Đây là câu hỏi thứ hai. Chú ý là cái đầu tiên là một câu hỏi cơ bản,
cái thứ hai là ChoiceQuestion. Tôi đã truyền cả 2 cái vào presentQuestion method.
Chỉ có 1 method thôi, nó ở đây, và parameter của nó là kiểu Question.
Nhưng ta vẫn truyền ChoiceQuestion vào question parameter được.
Bạn luôn có thể chuyển đổi từ subclass sang superclass.