All that moves

  • 3
  • Locked
We are going to create an interface for anything that can move. We'll call it CanMove and give it a speed method. And CanMove will be inherited by all things that moveth upon the ground, and that which moveth through the air. And each shall have its own speed method. And then thou shalt behold it and see a job well done!
You can't complete this task, because you're not signed in.
Comments (10)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Justin Smith
Level 39 , Greenfield, USA, United States
30 July 2021, 15:32
This task and the previous task really confused me. Both of them have an interface with a method that calls the interface itself as a parameter. Although I can get the solution to complete the task, I don't really understand what this means. I recommend that you update the lesson on interfaces that comes before this to make this clearer. Judging from the comments it seems like others are confused as well.
Level 20 , Poland
14 November 2020, 19:25
It was really hard task because I didn't understand what they wanted from me.. the key is in method in CanFly interface: Double speed(CanFly fly); I hope I helped you:)
Tom ford
Level 15
19 October 2020, 23:04
Could someone explain how the CanFly interface can be used as a parameter but it is an interface....wouldn't the interface have to be initialized into an object for this to occur?
Oliver Heintz
Level 18 , Mustang, United States
30 November 2020, 15:07
This also confused me. I'm not sure what is happening here.
John Squirrels Website Admin at CodeGym
1 December 2020, 09:21
What exactly do you mean by that?
Oliver Heintz
Level 18 , Mustang, United States
2 December 2020, 16:02
I guess interface as a parameter is confusing to me. I just can't wrap my head around it. Which is also confusing because I seem to grasp the idea of interfaces and abstract classes just fine, while a lot of the comments seem to be people not understand the same.
Justin Smith
Level 39 , Greenfield, USA, United States
30 July 2021, 15:37
This really threw me for a loop. I had to google a bit to understand what's going on here. Here is what I understand: If a method contains an interface parameter, it means that when you call that method, you can pass any object that implements that interface.
Level 22 , Cairns, Australia
13 October 2020, 14:46
i see what you did there.... a Double eh?
Level 20 , Toronto, Canada
15 December 2019, 05:44
Can someone tell me how to return A Double ? Thx.
Level 22 , Budapest, Hungary
28 July 2019, 15:27
tip: pay attention to returning Objects, not primitives