"Hello, Amigo! Soon you'll be dreaming of interfaces. So I wouldn't sleep if I were you. No way! Ha, ha! Here are a couple of little exercises for you. May interfaces ever remain in your brain."
3
Task
Java Core,
level 2,
lesson 9
Locked
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
Task
Java Core,
level 2,
lesson 9
Locked
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
Task
Java Core,
level 2,
lesson 9
Locked
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
Task
Java Core,
level 2,
lesson 9
Locked
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
Task
Java Core,
level 2,
lesson 9
Locked
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.
GO TO FULL VERSION