gime me a code for my full understanding.thanks
help me pls
Under discussion
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
Denis
26 June 2019, 16:20
Find the error in the logic: Duck should correctly implement the CanMove interface.
Fix the bug.
The output should be:
Flying
Moving
Requirements:
• The screen output must match the task conditions.
• The Duck class must implement the doAnotherAction method.
• The Duck class's doAnotherAction() method should display "Moving".
• The Util class's move method should call the doAnotherAction method on the object passed to it.
• The Duck class must implement the CanMove interface.
• The Duck class must implement the CanFly interface.
package com.codegym.task.task15.task1520;
/*
Brain training
*/
public class Solution {
public static void main(String[] args) {
Duck duck = new Duck();
Util.fly(duck);
Util.move(duck);
}
public static class Duck implements CanFly, CanMove {
@Override
public void doAction() {
System.out.println("Flying");
}
}
public static class Util {
static void fly(CanFly animal) {
animal.doAction();
}
static void move(CanMove animal) {
animal.doAction();
}
}
public static interface CanFly {
void doAction();
}
public static interface CanMove {
void doAnotherAction();
}
}
0
Dusernajder
15 August 2019, 08:40
You could provide your code via that little icon at the bottom when you ask a question.
And you will never learn programming if you asking for the solution, if you get a job as a dev no one will stand beside you and tell you what to do and what not.
You could ask questions but never the answer, that's a bad habit.
I've seen a lot of "questions" like this, I don't want to be hostile or anything close to that I just wanted to tell you that this can not go on when you are at work.
+2