idzik

Java-Klasy-Dziedziczenie-Animal

Nov 7th, 2016
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.76 KB | None | 0 0
  1. package dziedziczenie;
  2.  
  3. public class Animal {
  4. private boolean hasTail;
  5. private int weight;
  6. public void eat(){
  7.     System.out.println("I'm eating now");
  8. }
  9. public void giveVoice(){
  10.     System.out.println("I'm giving voice now");
  11. }
  12. public Animal(boolean hasTail, int weight) {
  13.     super();
  14.     this.hasTail = hasTail;
  15.     this.weight = weight;
  16. }
  17. public Animal(){
  18.    
  19. }
  20. }
  21. //-----------------------------------------------------
  22. class Dog extends Animal{
  23.     private String owner;
  24.     private String breed;
  25.     private int age;
  26. public Dog(boolean hasTail, int weight,String owner, String breed, int age) {
  27.     super(hasTail, weight);
  28.     this.age=age;
  29.     this.breed=breed;
  30.     this.owner=owner;
  31.     // TODO Auto-generated constructor stub
  32. }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment