Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions .idea/AP-Workshop6.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions Animal.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
public abstract class Animal {
protected String name;
protected int age;
protected String info;
public Animal(String name ,int age , String info){
this.name = name;
this.age = age;
this.info = info;
}
public abstract void show();

public String getName() {
return name;
}

public int getAge() {
return age;
}

public String getInfo() {
return info;
}
}
12 changes: 12 additions & 0 deletions Bird.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
public abstract class Bird extends Animal {
protected int height;
public Bird(String name ,int age , String info , int height){
super(name , age , info);
this.height = height;
}

@Override
public void show() {
System.out.println(" name: " + name +" age: " + age +" height: " + height + " info: " + info);
}
}
10 changes: 10 additions & 0 deletions Cheetah.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
public class Cheetah extends Mammal implements Hunter{
public Cheetah(String name, int age, String info, int speed) {
super(name, age, info, speed);
}

@Override
public void hunt(Prey prey) {
System.out.println(getName() + " hunted " + prey.getName());
}
}
10 changes: 10 additions & 0 deletions Eagle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
public class Eagle extends Bird implements Hunter{
public Eagle(String name, int age, String info, int height) {
super(name, age, info, height);
}

@Override
public void hunt(Prey prey) {
System.out.println(getName() + " hunted " + prey.getName());
}
}
5 changes: 5 additions & 0 deletions Girafe.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public class Girafe extends Mammal implements Prey{
public Girafe(String name, int age, String info, int speed) {
super(name, age, info, speed);
}
}
3 changes: 3 additions & 0 deletions Hunter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public interface Hunter {
public void hunt(Prey prey);
}
20 changes: 20 additions & 0 deletions Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import java.util.ArrayList;

public class Main {
public static void main(String [] args){
ArrayList<Animal> animals = new ArrayList<>();
Cheetah cheetah1 = new Cheetah("simba" , 7 , "fast as rocket" , 100);
Parrot bird1 = new Parrot("rio" , 2 , "talkative" ,30);
Girafe girafe1 = new Girafe("lucas" , 4 , " tall but shy" , 10);
Eagle eagle1 = new Eagle("max" , 10 , "lives in mountain" , 500 );
animals.add(cheetah1);
animals.add(bird1);
animals.add(girafe1);
animals.add(eagle1);
for (Animal animal : animals){
animal.show();
}
cheetah1.hunt(girafe1);
eagle1.hunt(bird1);
}
}
11 changes: 11 additions & 0 deletions Mammal.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
public abstract class Mammal extends Animal {
protected int speed;
public Mammal(String name ,int age , String info , int speed){
super(name , age ,info);
this.speed = speed;
}
@Override
public void show() {
System.out.println(" name: " + name +" age:" + age +" speed: " + speed + " info: " + info);
}
}
5 changes: 5 additions & 0 deletions Parrot.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public class Parrot extends Bird implements Prey{
public Parrot(String name, int age, String info, int height) {
super(name, age, info, height);
}
}
3 changes: 3 additions & 0 deletions Prey.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public interface Prey {
public String getName();
}
8 changes: 8 additions & 0 deletions out/production/AP-Workshop6/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions out/production/AP-Workshop6/.idea/AP-Workshop6.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions out/production/AP-Workshop6/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions out/production/AP-Workshop6/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions out/production/AP-Workshop6/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added out/production/AP-Workshop6/Animal.class
Binary file not shown.
Binary file added out/production/AP-Workshop6/Bird.class
Binary file not shown.
Binary file added out/production/AP-Workshop6/Cheetah.class
Binary file not shown.
Binary file added out/production/AP-Workshop6/Eagle.class
Binary file not shown.
Binary file added out/production/AP-Workshop6/Girafe.class
Binary file not shown.
Binary file added out/production/AP-Workshop6/Hunter.class
Binary file not shown.
Binary file added out/production/AP-Workshop6/Main.class
Binary file not shown.
Binary file added out/production/AP-Workshop6/Mammal.class
Binary file not shown.
Binary file added out/production/AP-Workshop6/Parrot.class
Binary file not shown.
Binary file added out/production/AP-Workshop6/Prey.class
Binary file not shown.
Empty file.