diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/AP-Workshop6.iml b/.idea/AP-Workshop6.iml new file mode 100644 index 0000000..b107a2d --- /dev/null +++ b/.idea/AP-Workshop6.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..15cec4b --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..8492c7d --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Animal.java b/Animal.java new file mode 100644 index 0000000..7537834 --- /dev/null +++ b/Animal.java @@ -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; + } +} diff --git a/Bird.java b/Bird.java new file mode 100644 index 0000000..c1c6eca --- /dev/null +++ b/Bird.java @@ -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); + } +} diff --git a/Cheetah.java b/Cheetah.java new file mode 100644 index 0000000..e10c853 --- /dev/null +++ b/Cheetah.java @@ -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()); + } +} diff --git a/Eagle.java b/Eagle.java new file mode 100644 index 0000000..8dfc2ce --- /dev/null +++ b/Eagle.java @@ -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()); + } +} diff --git a/Girafe.java b/Girafe.java new file mode 100644 index 0000000..c4c38ca --- /dev/null +++ b/Girafe.java @@ -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); + } +} diff --git a/Hunter.java b/Hunter.java new file mode 100644 index 0000000..6d8780d --- /dev/null +++ b/Hunter.java @@ -0,0 +1,3 @@ +public interface Hunter { + public void hunt(Prey prey); +} diff --git a/Main.java b/Main.java new file mode 100644 index 0000000..328eaa1 --- /dev/null +++ b/Main.java @@ -0,0 +1,20 @@ +import java.util.ArrayList; + +public class Main { + public static void main(String [] args){ + ArrayList 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); + } +} diff --git a/Mammal.java b/Mammal.java new file mode 100644 index 0000000..e506002 --- /dev/null +++ b/Mammal.java @@ -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); + } +} diff --git a/Parrot.java b/Parrot.java new file mode 100644 index 0000000..24d1e39 --- /dev/null +++ b/Parrot.java @@ -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); + } +} diff --git a/Prey.java b/Prey.java new file mode 100644 index 0000000..876fa3d --- /dev/null +++ b/Prey.java @@ -0,0 +1,3 @@ +public interface Prey { + public String getName(); +} diff --git a/out/production/AP-Workshop6/.idea/.gitignore b/out/production/AP-Workshop6/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/out/production/AP-Workshop6/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/out/production/AP-Workshop6/.idea/AP-Workshop6.iml b/out/production/AP-Workshop6/.idea/AP-Workshop6.iml new file mode 100644 index 0000000..b107a2d --- /dev/null +++ b/out/production/AP-Workshop6/.idea/AP-Workshop6.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/out/production/AP-Workshop6/.idea/misc.xml b/out/production/AP-Workshop6/.idea/misc.xml new file mode 100644 index 0000000..15cec4b --- /dev/null +++ b/out/production/AP-Workshop6/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/out/production/AP-Workshop6/.idea/modules.xml b/out/production/AP-Workshop6/.idea/modules.xml new file mode 100644 index 0000000..8492c7d --- /dev/null +++ b/out/production/AP-Workshop6/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/out/production/AP-Workshop6/.idea/vcs.xml b/out/production/AP-Workshop6/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/out/production/AP-Workshop6/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/out/production/AP-Workshop6/Animal.class b/out/production/AP-Workshop6/Animal.class new file mode 100644 index 0000000..f21f35c Binary files /dev/null and b/out/production/AP-Workshop6/Animal.class differ diff --git a/out/production/AP-Workshop6/Bird.class b/out/production/AP-Workshop6/Bird.class new file mode 100644 index 0000000..4db9bea Binary files /dev/null and b/out/production/AP-Workshop6/Bird.class differ diff --git a/out/production/AP-Workshop6/Cheetah.class b/out/production/AP-Workshop6/Cheetah.class new file mode 100644 index 0000000..22fa1ce Binary files /dev/null and b/out/production/AP-Workshop6/Cheetah.class differ diff --git a/out/production/AP-Workshop6/Eagle.class b/out/production/AP-Workshop6/Eagle.class new file mode 100644 index 0000000..b8f726b Binary files /dev/null and b/out/production/AP-Workshop6/Eagle.class differ diff --git a/out/production/AP-Workshop6/Girafe.class b/out/production/AP-Workshop6/Girafe.class new file mode 100644 index 0000000..e807ffe Binary files /dev/null and b/out/production/AP-Workshop6/Girafe.class differ diff --git a/out/production/AP-Workshop6/Hunter.class b/out/production/AP-Workshop6/Hunter.class new file mode 100644 index 0000000..f5d1af6 Binary files /dev/null and b/out/production/AP-Workshop6/Hunter.class differ diff --git a/out/production/AP-Workshop6/Main.class b/out/production/AP-Workshop6/Main.class new file mode 100644 index 0000000..7b5d5d7 Binary files /dev/null and b/out/production/AP-Workshop6/Main.class differ diff --git a/out/production/AP-Workshop6/Mammal.class b/out/production/AP-Workshop6/Mammal.class new file mode 100644 index 0000000..fb23609 Binary files /dev/null and b/out/production/AP-Workshop6/Mammal.class differ diff --git a/out/production/AP-Workshop6/Parrot.class b/out/production/AP-Workshop6/Parrot.class new file mode 100644 index 0000000..8b7fd2f Binary files /dev/null and b/out/production/AP-Workshop6/Parrot.class differ diff --git a/out/production/AP-Workshop6/Prey.class b/out/production/AP-Workshop6/Prey.class new file mode 100644 index 0000000..970f10b Binary files /dev/null and b/out/production/AP-Workshop6/Prey.class differ diff --git a/out/production/AP-Workshop6/ReadMe.md b/out/production/AP-Workshop6/ReadMe.md new file mode 100644 index 0000000..e69de29