Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
public class JavaApplication1 { | ||
|
||
/** | ||
*/ | ||
|
||
// Interface just contains the definations that needs to be implemented whoever | ||
// conforms to the Animal interface - It's like a basketball coach who doesn't know | ||
// how to play but can teach other about it. | ||
public interface Animal{ | ||
public String eat(); | ||
public void run(); | ||
public void jump(); | ||
} | ||
|
||
|
||
public class ZooAnimals implements Animal{ | ||
|
||
public String eat; | ||
public String run; | ||
public String jump; | ||
|
||
// This is a constructure method. | ||
public ZooAnimals(String eat, String run, String jump){ | ||
this.eat = eat; | ||
this.jump = jump; | ||
this.run = run; | ||
} | ||
|
||
@Override | ||
public String eat() { | ||
return this.eat; | ||
} | ||
|
||
@Override | ||
public void run() { | ||
System.out.println(this.run); | ||
} | ||
|
||
@Override | ||
public void jump() { | ||
System.out.println(this.jump); | ||
} | ||
|
||
} | ||
|
||
public void animalInformation(){ | ||
ZooAnimals x; | ||
x = new ZooAnimals("Eat fresh", "Can run fast", "Cannot jump high"); | ||
String result = x.eat(); | ||
System.out.println(result); | ||
} | ||
|
||
public static void main(String[] args) { | ||
// TODO code application logic here | ||
JavaApplication1 j1 = new JavaApplication1(); | ||
j1.animalInformation(); | ||
|
||
} | ||
|
||
} |