clanecollege

Animal.java

May 17th, 2012
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. public class Animal
  2. {
  3.     private String gender;
  4.     private int legs;
  5.     private String eyes;
  6.     private int tail;
  7.  
  8.     public Animal()
  9.     {
  10.         this.gender = "male";
  11.         this.legs = 2;
  12.         this.eyes = "blue";
  13.         this.tail = 0;
  14.     }
  15.  
  16.     public String getGender()
  17.     {
  18.         return gender;
  19.     }
  20.  
  21.     public int getLegs()
  22.     {
  23.         return legs;
  24.     }
  25.  
  26.     public String getEyes()
  27.     {
  28.         return eyes;
  29.     }
  30.  
  31.     public int getTail()
  32.     {
  33.         return tail;
  34.     }
  35.  
  36.     public void setGender(String gender)
  37.     {
  38.         this.gender = gender;
  39.     }
  40.  
  41.     public void setLegs(int legs)
  42.     {
  43.         this.legs = legs;
  44.     }
  45.  
  46.     public void setEyes(String eyes)
  47.     {
  48.         this.eyes = eyes;
  49.     }
  50.  
  51.     public void setTail(int tail)
  52.     {
  53.         this.tail = tail;
  54.     }
  55.  
  56.     public void printDetails()
  57.     {
  58.         System.out.println("Gender: " + gender + "\nLegs: " + legs
  59.                 + "\nEyes: " + eyes + "\nTail: " + tail+"\n");
  60.     }
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment