dm6801

171127 - Class 08 - StreetCat

Nov 28th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.04 KB | None | 0 0
  1. package Cats;
  2.  
  3. public class StreetCat extends Cat {
  4.     /* Properties */
  5.     protected int fights;
  6.    
  7.    
  8.     /* Get, Set Methods */
  9.     public void setFights(int fights) {
  10.         if (fights < 0) { fights = 0; }
  11.         this.fights = fights;
  12.     }
  13.     public int getFights() {
  14.         return this.fights;
  15.     }
  16.    
  17.    
  18.     /* Constructors */
  19.     public StreetCat(String name, float whiskersLength, String colour, int fights) {
  20.         super(name, whiskersLength, colour);
  21.         this.fights = fights;
  22.     }
  23.     public StreetCat(String name, float whiskersLength, String colour) {
  24.         super(name, whiskersLength, colour);
  25.     }
  26.     public StreetCat(String name, float whiskersLength) {
  27.         super(name, whiskersLength);
  28.     }
  29.     public StreetCat(String name) {
  30.         super(name);
  31.     }
  32.     public StreetCat() {
  33.         super();
  34.     }
  35.     /* Cat class copy constructor */
  36.     public StreetCat(Cat catObj, int fights) {
  37.         super(catObj);
  38.         setFights(fights);
  39.     }
  40.     public StreetCat(Cat catObj) {
  41.         super(catObj);
  42.         setFights(0);
  43.     }
  44.    
  45.     /* Methods */
  46.     public String toString() {
  47.         return super.toString() + "\tfights="+fights;
  48.     }
  49.    
  50.    
  51. }
Add Comment
Please, Sign In to add comment