Skip to content
Snippets Groups Projects
Commit 6685023b authored by Juuso Rytilahti's avatar Juuso Rytilahti
Browse files

Added exercise 3

parent 35deba7b
No related branches found
No related tags found
No related merge requests found
package fi.utu.tech.ooj.exercise4.exercise3;
interface Winged {
default void fly() {
System.out.println(this + " flies!");
}
}
interface Bipedal {
default void walk() {
System.out.println(this + " walks!");
}
}
abstract class Bird implements Winged, Bipedal {
}
class Crow extends Bird {
private static int idx = 0;
private int id = ++idx;
@Override
public String toString() {
return "Varis " + id;
}
}
public class Teht3 {
public Teht3() {
System.out.println("Exercise 3");
challenge1(new Crow());
challenge2(new Crow());
}
void challenge1(Bird b) {
System.out.println("In this challenge, we fly and then we walk!");
b.fly();
b.walk();
}
<X extends Winged & Bipedal> void challenge2(X b) {
System.out.println("In this challenge, we fly and then we walk!");
b.fly();
b.walk();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment