109 lines
2.2 KiB
Java
109 lines
2.2 KiB
Java
/**
|
|
* <PRE>
|
|
* Fish.java
|
|
*
|
|
* Revisions: 1.0 Sep. 18, 2002
|
|
* Created the Fish class
|
|
* 1.1 Sep. 18, 2002
|
|
* Finished the Fish class
|
|
* 1.1f Sep. 18, 2002
|
|
* Cleaned up equals() to make more readable
|
|
* </PRE>
|
|
*
|
|
* Collaboration Statement:
|
|
* I worked on the homework assignment alone, using only
|
|
* course materials.
|
|
*
|
|
* Created with JCreatorLE, some indents are off when viewed through notepad
|
|
* or EMACS
|
|
*
|
|
* @author <A HREF="mailto:gtg184g@mail.gatech.edu">Jose Manuel Caban</A>
|
|
* @version Version 1.1f, Sep. 18, 2002
|
|
*/
|
|
|
|
public abstract class Fish extends Animal implements SwimmingType{
|
|
|
|
/**
|
|
*depth of Fish
|
|
*/
|
|
private int depth;
|
|
|
|
////////////////
|
|
//Constructors//
|
|
////////////////
|
|
|
|
/**
|
|
*Constructor for Fish
|
|
*@param name, the name of the fish
|
|
*@param depth, the depth of the fish
|
|
*/
|
|
public Fish(String name, int depth){
|
|
super(name);
|
|
this.setDepth(depth);
|
|
}
|
|
|
|
///////////////////////
|
|
//Accessors/Modifiers//
|
|
///////////////////////
|
|
|
|
/**
|
|
*Set the depth of Fish
|
|
*@param depth the value to be applied
|
|
*/
|
|
public void setDepth(int depth){
|
|
if(depth < 0){
|
|
this.depth = 0;
|
|
}
|
|
else{
|
|
this.depth = depth;
|
|
}
|
|
}
|
|
|
|
/**
|
|
*Return the depth of the Fish
|
|
*@return the value of depth
|
|
*/
|
|
public int getDepth(){
|
|
return depth;
|
|
}
|
|
|
|
///////////
|
|
//Methods//
|
|
///////////
|
|
|
|
/**
|
|
*Find the equality of Fish
|
|
*@param obj the Object to be compared to
|
|
*@return the equality value
|
|
*/
|
|
public boolean equals(Object obj){
|
|
|
|
if(!(obj instanceof Fish)){
|
|
return false;
|
|
}
|
|
if(!super.equals(obj)){
|
|
return false;
|
|
}
|
|
|
|
Fish fTemp = (Fish)obj;
|
|
//use of "this." is to make it explicit
|
|
if(fTemp.getDepth() != this.getDepth()){
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Debugging main for class Fish.
|
|
* This method will rigorously test my code.
|
|
*
|
|
* <br><br>
|
|
* @param args a String array of command line arguments.
|
|
*/
|
|
public static void main(String[] args) {
|
|
|
|
|
|
}// end of main(String[] args)
|
|
|
|
}// end of class Fish
|