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!
All that moves
- 3
Locked
Comments (10)
- Popular
- New
- Old
You must be signed in to leave a comment
Justin Smith
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.
+4
Vitalina
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:)
+2
Tom ford
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?
+4
Oliver Heintz
30 November 2020, 15:07
This also confused me. I'm not sure what is happening here.
0
John Squirrels Website Admin at CodeGym
1 December 2020, 09:21
What exactly do you mean by that?
0
Oliver Heintz
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.
0
Justin Smith
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.
+1
MoJo
13 October 2020, 14:46
i see what you did there.... a Double eh?
0
yi
15 December 2019, 05:44
Can someone tell me how to return A Double ? Thx.
0
Zserbo
28 July 2019, 15:27
tip: pay attention to returning Objects, not primitives
+1