「こんにちは、アミーゴ! もうすぐあなたはインターフェイスの夢を見るでしょう。だから、私があなただったら眠れません。そんなはずはない! ハッ、ハッ! ここであなたにいくつかの小さな練習問題を紹介します。インターフェイスがあなたの脳に残りますように。 」
3
タスク
Java Core, レベル 2, レッスン 9
Wanna fly?
Rishi Gatesman, a CodeGym teacher, used to say that the interface is the legitimate child of Abstraction and Polymorphism. Let's start studying it. Have you ever flown in a dream? Have you ever dreamed of actually flying? Here's your task: implement the CanFly interface with two methods. Can you do it?
3
タスク
Java Core, レベル 2, レッスン 9
Fly, run and swim
It would be awesome to be Superman! He flies fast as lightning, outruns the wind, and swims like a fish. Wait, can Superman even swim? Whatever, doesn't matter. Write a generic template for a superhero that can fly, swim, and run. You need to do this by implementing the CanFly, CanRun, and CanSwim interfaces.
3
タスク
Java Core, レベル 2, レッスン 9
Eat, fly, and move
Some kind soul already wrote for you perfect interfaces for flying, moving, and eating. Let's add these interfaces to the dog, duck, car, and airplane classes. Let common sense be your guide as you dream up the solution. Sometimes common sense is a programmer's best friend.
3
タスク
Java Core, レベル 2, レッスン 9
Making a human
No fancy bells and whistles in this task. We simply need to correctly associate the CanFly, CanRun, and CanSwim interfaces with the Human, Duck, Penguin, and Airplane classes. Can you do it? Carry on! Don't know how? Go study the corresponding lesson, and then - carry on!
3
タスク
Java Core, レベル 2, レッスン 9
Human class and CanRun and CanSwim interfaces
Once again, like real programmers, we have to create a human. And, as always, we will accomplish this by writing code. Alas. We'll grant our human the Run and Swim interfaces, but we won't implement them. Because our man is abstract. Make sense? If not, it's time to review the lessons on abstract classes and interfaces.