„Здравей, Амиго! Скоро ще сънуваш интерфейси. Така че на твое място не бих заспал. Няма начин! Ха, ха! Ето няколко малки упражнения за теб. Нека интерфейсите винаги да останат в мозъка ти. "
3
Задача
Java Core, ниво, урок
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, ниво, урок
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, ниво, урок
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, ниво, урок
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, ниво, урок
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.