Advertisement
MrsMcLead

Cat

Mar 4th, 2014
442
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.78 KB | None | 0 0
  1. public class Cat{
  2.  
  3.   private String color;   //color of the cat's fur
  4.   private double size;    //size in centimeters
  5.   private String species;
  6.   private String eyeColor;
  7.   private boolean isFriendly;  //subjective friendliness assignment
  8.  
  9.   public Cat() //default constructor
  10.   {
  11.     color = "red";
  12.     size = 1;
  13.     species = "Maine Coon Cat";
  14.     eyeColor = "green";
  15.     isFriendly = true;
  16.    
  17.   }
  18.  
  19.   public Cat(String clr, double sz, String spcs, String eye, boolean isFrndly)
  20.   {
  21.      color = clr;
  22.     size = sz;
  23.     species = spcs;
  24.     eyeColor = eye;
  25.     isFriendly = isFrndly;
  26.        
  27.   }
  28.  
  29.   public String toString()
  30.   {
  31.     String str = "My cat is colored " +  color + " and has size: " + size + "cm. \nIt is a " + species +
  32.       " with " + eyeColor + " eyes.";
  33.     if(isFriendly)
  34.     {
  35.       str = str+" It is friendly.";
  36.     }
  37.     else
  38.     {
  39.       str = str + " It is mean.";
  40.     }
  41.     str = str + "\n";
  42.    
  43.     return str;
  44.    
  45.     }
  46.  
  47.   public void setColor(String clr)
  48.   {
  49.    color = clr;
  50.   }
  51.  
  52.   public String getColor()
  53.   {
  54.    return color;
  55.   }
  56.  
  57.   public void setSize(double sz)
  58.   {
  59.     size = sz;
  60.   }
  61.  
  62.   public double getSize()
  63.   {
  64.     return size;
  65.   }
  66.  
  67.   public void setSpecies(String spcs)
  68.   {
  69.     species = spcs;
  70.   }
  71.  
  72.   public String getSpecies()
  73.   {
  74.     return species;
  75.   }
  76.  
  77.   public void setEyeColor(String eye)
  78.   {
  79.     eyeColor = eye;
  80.   }
  81.  
  82.   public String getEyeColor()
  83.   {
  84.     return eyeColor;
  85.   }
  86.  
  87.   public void setIsFriendly(boolean frndly)
  88.   {
  89.    isFriendly = frndly;
  90.   }
  91.  
  92.   public boolean getIsFriendly()
  93.   {
  94.     return isFriendly;
  95.   }
  96.  
  97.   public void sleep()
  98.   {
  99.    System.out.println("ZZZZZZ.... \n");
  100.   }
  101.  
  102.   public void grow()
  103.   {
  104.     size++;
  105.   }
  106.  
  107.    
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement