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 Examples/workshop_6/.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 Examples/workshop_6/.idea/example.iml

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

6 changes: 6 additions & 0 deletions Examples/workshop_6/.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 Examples/workshop_6/.idea/modules.xml

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

36 changes: 36 additions & 0 deletions Examples/workshop_6/A.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
public class A extends B{
private int aInt;
public A(int aInt, int bInt) {
super(bInt);
this.aInt = aInt;
}

@Override
public void show(){
System.out.println("salam a");
}

public static void main(String[] args) {
// A a = new A(10, 20);
// if(a instanceof A){
// System.out.println("yes a is instanceof A");
// }
// if(a instanceof B){
// System.out.println("yes a is instanceof B");
// }
// B b = new B(100);
// if(!(b instanceof A)){
// System.out.println("yes b isn't instanceof A");
// }
// B c = null;
// if(!(c instanceof B)){
// System.out.println("yes null isn't instanceof B");
// }
// B obj1 = new A(5, 5);
// A objA1 = (A)obj1;
// B obj2 = new B(10);
// A objA2 = (A)obj2;
A test = new A(1, 2);
test.show();
}
}
11 changes: 11 additions & 0 deletions Examples/workshop_6/B.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
public class B {
private int bInt;

public B(int bInt) {
this.bInt = bInt;
}

public void show(){
System.out.println("salam b");
}
}
8 changes: 8 additions & 0 deletions Examples/workshop_6/out/production/example/.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 Examples/workshop_6/out/production/example/.idea/example.iml

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

6 changes: 6 additions & 0 deletions Examples/workshop_6/out/production/example/.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 Examples/workshop_6/out/production/example/.idea/modules.xml

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

8 changes: 8 additions & 0 deletions Practice_codes/workshop_6/.idea/.gitignore

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

6 changes: 6 additions & 0 deletions Practice_codes/workshop_6/.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 Practice_codes/workshop_6/.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 Practice_codes/workshop_6/.idea/vcs.xml

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

6 changes: 6 additions & 0 deletions Practice_codes/workshop_6/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 Practice_codes/workshop_6/WorkShop6/.idea/modules.xml

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

7 changes: 7 additions & 0 deletions Practice_codes/workshop_6/WorkShop6/.idea/vcs.xml

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

63 changes: 63 additions & 0 deletions Practice_codes/workshop_6/WorkShop6/.idea/workspace.xml

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

11 changes: 11 additions & 0 deletions Practice_codes/workshop_6/WorkShop6/WorkShop6.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
13 changes: 13 additions & 0 deletions Practice_codes/workshop_6/WorkShop6/src/Animal.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
public abstract class Animal {
protected String name;
protected int age;
protected String special;

public Animal(String name, int age, String special) {
this.name = name;
this.age = age;
this.special = special;
}

public abstract void show();
}
8 changes: 8 additions & 0 deletions Practice_codes/workshop_6/WorkShop6/src/Bird.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
public abstract class Bird extends Animal{
protected int heightOfFly;

public Bird(String name, int age, String special, int heightOfFly) {
super(name, age, special);
this.heightOfFly = heightOfFly;
}
}
16 changes: 16 additions & 0 deletions Practice_codes/workshop_6/WorkShop6/src/Cheetah.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
public class Cheetah extends Mammal implements Hunter{
public Cheetah(String name, int age, String special, int speedOfRunning) {
super(name, age, special, speedOfRunning);
}

@Override
public void hunt(Prey prey) {
System.out.println(name + " hunted " + prey.getName());
}

@Override
public void show() {
System.out.println("Name : " + name + " Age : " + age + " Speed of running : " + speedOfRunning +
" special : " + special);
}
}
16 changes: 16 additions & 0 deletions Practice_codes/workshop_6/WorkShop6/src/Eagle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
public class Eagle extends Bird implements Hunter{
public Eagle(String name, int age, String special, int heightOfFly) {
super(name, age, special, heightOfFly);
}

@Override
public void hunt(Prey prey) {
System.out.println(name + " hunted " + prey.getName());
}

@Override
public void show() {
System.out.println("Name : " + name + " Age : " + age + " Hight of fly : " + heightOfFly +
" special : " + special);
}
}
17 changes: 17 additions & 0 deletions Practice_codes/workshop_6/WorkShop6/src/Girafe.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
public class Girafe extends Mammal implements Prey{
public Girafe(String name, int age, String special, int speedOfRunning) {
super(name, age, special, speedOfRunning);
}

@Override
public String getName() {
return name;
}

@Override
public void show() {
System.out.println("Name : " + name + " Age : " + age + " Speed of running : " + speedOfRunning +
" special : " + special);
}

}
5 changes: 5 additions & 0 deletions Practice_codes/workshop_6/WorkShop6/src/Hunter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import java.security.PublicKey;

public interface Hunter {
public void hunt(Prey prey);
}
23 changes: 23 additions & 0 deletions Practice_codes/workshop_6/WorkShop6/src/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import java.util.ArrayList;

public class Main {
public static void main(String[] args) {
ArrayList<Animal> arr = new ArrayList<>();
Parrot parrot = new Parrot("parrot1", 10, "sp", 100);
Cheetah cheetah = new Cheetah("cheetah1", 4, "sp2", 200);
Eagle eagle = new Eagle("eagle1", 3, "sp3", 182);
Girafe girafe = new Girafe("girafe1", 32, "sp4", 12);
arr.add(parrot);
arr.add(cheetah);
arr.add(eagle);
arr.add(girafe);
int idx = 0;
for(Animal animal : arr){
System.out.printf("row : " + idx + " ");
animal.show();
idx ++;
}
cheetah.hunt(girafe);
eagle.hunt(parrot);
}
}
8 changes: 8 additions & 0 deletions Practice_codes/workshop_6/WorkShop6/src/Mammal.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
public abstract class Mammal extends Animal {
protected int speedOfRunning;

public Mammal(String name, int age, String special, int speedOfRunning) {
super(name, age, special);
this.speedOfRunning = speedOfRunning;
}
}
Loading