Created
June 30, 2016 22:25
-
-
Save Yurlov/2aa1cb7d48328929739ac6a77ff93ce6 to your computer and use it in GitHub Desktop.
Prog.kiev.ua
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
class Animals { | |
private String name; | |
private int age; | |
private String color; | |
public int getAge() { | |
return age; | |
} | |
public void setAge(int age) { | |
this.age = age; | |
} | |
public String getName() { | |
return name; | |
} | |
public void setName(String name) { | |
this.name = name; | |
} | |
public String getBreed() { | |
return breed; | |
} | |
public void setBreed(String breed) { | |
this.breed = breed; | |
} | |
public String getColor() { | |
return color; | |
} | |
public void setColor(String color) { | |
this.color = color; | |
} | |
@Override | |
public String toString(){ | |
return "Имя : "+name; | |
} | |
} |
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
public class Dog extends Animals { | |
public void getVoice(){ | |
System.out.println(getName()+" Grrrrr"); | |
} | |
public void getJump(){ | |
System.out.println(getName()+" is jumping"); | |
} | |
public void getBite(){ | |
System.out.println(getName()+ " bites "); | |
} | |
public void getRun(){ | |
System.out.println(getName()+" is running!"); | |
} | |
} |
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
public class Puppy extends Dog{ | |
public static void main(String[] args) { | |
Puppy puppy = new Puppy(); | |
puppy.setName("Ben"); | |
System.out.println(puppy.toString()); | |
puppy.getBite(); | |
puppy.getRun(); | |
puppy.getJump(); | |
puppy.getVoice(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment