So we wanted to make this dog move, simple enough. We simply make the dog move
just the same as the car. But of course now we have to edit the dog class, and
make the movement happen. There's the dog class. We add Moveable to the list of
interfaces. And here's my move method. It's simply enough, I simply move both
the picture of the dog and the name text. And I was asked to move it vertically
at one pixel per second. That's why the horizontal displacement is zero and the
vertical displacement is the same as the seconds. When you run the program,
then here you can see the car move, and the dog move.
Así que queríamos hacer que este perro se mueva, bastante simple. Simplemente hacemos que el perro se mueva
justo igual que lo hicimos con el coche. Pero, por supuesto, ahora tenemos que editar la clase Perro y
hacer que el movimiento ocurra. Aquí está la clase Perro. Añadimos Movibles a la lista de
interfaces. Y aquí está mi método move. Es bastante fácil, simplemente muevo tanto
la imagen del perro como el texto del nombre. Y me pidieron que lo moviera en sentido vertical
en un pixel por segundo. Es por eso que el desplazamiento horizontal es cero y el
desplazamiento vertical es el mismo que los segundos. Cuando se ejecuta el programa,
entonces aquí se puede ver que el coche se mueve y que el perro se mueve.
Nous voulions donc faire bouger ce chien.
Assez simple.
Nous faisons simplement bouger le chien
de la même manière que la voiture.
Mais bien sûr, maintenant nous
devons éditer la classe Dog,
et créer le mouvement.
Voici la classe Dog.
Nous ajoutons Moveable à
la liste des interfaces.
Et voici ma méthode de déplacement.
C'est assez simple,
je déplace simplement à la fois l'image
du chien et le texte du nom.
Et on m'a demandé de le déplacer
verticalement à un pixel par seconde.
C'est pourquoi le déplacement
horizontal est nul
et le déplacement vertical
est égal aux secondes.
Lorsque vous exécutez le programme,
vous pouvez voir la voiture
se déplacer ainsi que le chien.
では犬を動かしましょう とても簡単です
方法は車と同じです
もちろん今度はDogクラスを編集して
動きを追加します ここにDogクラスがあります
インターフェースのリストにMovableを追加します
ここにmoveメソッドがあります
犬の画像と名前のテキストの両方を
毎秒1ピクセルで
垂直に動かします 従って水平移動はゼロで
垂直移動はこの秒数になります
このプログラムを実行すると
車と犬が動くのが確認できますね
이 강아지를 움직이게 해봅시다. 자동차와 똑같이 dog1.move()를
추가합니다. 하지만 Dog 클래스를 수정해서 움직일 수 있게
합니다. 인터페이스 목록에 Moveable을 추가합니다.
여기에 move 메소드를 구현했습니다. 굉장히 간단합니다. 강아지 사진과
강아지 이름 텍스트를 같이 옮깁니다. 그리고 옆으로 1초당 10픽셀을
움직이도록 했습니다. 그래서 세로 쪽은 0입니다.
이 프로그램을 실행하면,
강아지와 자동차가 움직이는 것을 볼 수 있습니다.
Ta muốn chú chó này di chuyển, dễ thôi. Cũng giống như khi làm với chiếc xe.
Nhưng tất nhiên, bây giờ ta phải sửa Dog class,
và làm cho sự di chuyển xảy ra. Đây là Dog class. Ta thêm Movable vào làm interface.
Và đây là move method. Đó đơn giản, ta chỉ di chuyển cả 2 bức hình
của con chó và tên nó. Và tôi làm cho nó
di chuyển theo chiều dọc, 1 pixel per second. Đó là lý do sự thay đổi theo chiều ngang = 0,
và thay đổi theo chiều dọc bằng số giây. Khi bạn chạy chương trình,
bạn thấy là chiếc xe di chuyển, và con chó nữa.