diff --git a/assignments/AssigmentS1/Dachshund.java b/assignments/AssigmentS1/Dachshund.java new file mode 100644 index 0000000..d88669b --- /dev/null +++ b/assignments/AssigmentS1/Dachshund.java @@ -0,0 +1,25 @@ +package assignments.AssigmentS1; + +class Dachshund extends Dog { + int length = 1000; + + Dachshund() { + name = "German Sausage"; + color = "Sausage Red"; + breed = "Sausage Dog"; + hungry = 0; // If 1 then hungry + } + + public String SausageLength() { + return length + " cm"; + } + + void setLength(int length) { + this.length = length; + } + + public String wag_tail() { + return "No wag, doing plank!!!"; + } + +} diff --git a/assignments/AssigmentS1/Dog.java b/assignments/AssigmentS1/Dog.java new file mode 100644 index 0000000..08209d4 --- /dev/null +++ b/assignments/AssigmentS1/Dog.java @@ -0,0 +1,50 @@ +package assignments.AssigmentS1; + +class Dog { + String name; + String color; // colour ? + String breed; + int hungry; // If 1 then hungry + + + Dog() { + name = "John Dog"; + color = "Brown"; + breed = "Street dog"; + hungry = 1; + + } + +public String bark() { + return "Woof! Woof!"; +} + +public String fetch() { + if (hungry != 1) { // In C if(!hungry) {} + return "Here's stick!"; + } else { + return "Too hungry!"; + } +} + +public String wag_tail() { + return "Little wag!"; +} + +void setName(String name) { + this.name = name; +} + +void setHungry(int hungry) { + this.hungry = hungry; +} + +void setColor(String color) { + this.color = color; +} + +void setBreed(String breed) { + this.breed = breed; +} + +} \ No newline at end of file diff --git a/assignments/AssigmentS1/DogDemo.java b/assignments/AssigmentS1/DogDemo.java new file mode 100644 index 0000000..8485fee --- /dev/null +++ b/assignments/AssigmentS1/DogDemo.java @@ -0,0 +1,39 @@ +package assignments.AssigmentS1; + +class DogDemo { + public static void main(String[] args) { + Kangal dog1 = new Kangal(); + Dog dog2 = new Kangal(); + Dog dog3 = new Dog(); + Dachshund dog4 = new Dachshund(); + + System.out.println(); + System.out.println(dog1.name); + dog1.setHungry(1); + System.out.println(dog1.wag_tail()); + dog1.protectedAnimal("Chicken"); + System.out.println(dog1.guard()); + + System.out.println(); + + dog2.setName("Kaplan Korur"); + System.out.println(dog2.name + ", " + dog2.breed + ", " + dog2.color); + dog2.setHungry(0); + System.out.println(dog2.wag_tail()); + // System.out.println(dog2.guard()); --> ERROR + + System.out.println(); + + System.out.println(dog3.name); + dog3.setHungry(0); + System.out.println(dog3.wag_tail()); + System.out.println(dog3.fetch()); + + System.out.println(); + + System.out.println(dog4.name +", " + dog4.color); + dog4.setHungry(1); + System.out.println(dog4.wag_tail()+ " Current length: " + dog4.SausageLength()); + System.out.println(dog4.fetch()); + } +} diff --git a/assignments/AssigmentS1/Kangal.java b/assignments/AssigmentS1/Kangal.java new file mode 100644 index 0000000..6616535 --- /dev/null +++ b/assignments/AssigmentS1/Kangal.java @@ -0,0 +1,27 @@ +package assignments.AssigmentS1; + +class Kangal extends Dog { + String Protects; + + Kangal() { + name = "Aslan Korur"; + color = "Yellow"; + breed = "Protect Dog"; + hungry = 0; // If 1 then hungry + Protects = "Sheep"; + } + + +public String guard() { + return "ON DUTY! and Protects: " + Protects; +} + +public String wag_tail() { + return "No wag!"; +} + +void protectedAnimal(String Protects) { + this.Protects = Protects; +} + +} \ No newline at end of file