Java program help
package lists;
/**
* This class represents different animal characteristics that are recorded by the user
*
*
*/
public class Animal {
private String name;
private String color;
private String type; //vertebrate or invertebrate
private boolean canSwim;
//Constructor
public Animal(){
}
/**
* Constructor with values
* @param name name of the animal
* @param color color of the animal
* @param type represents whether its vertebrate or invertebrate
* @param canSwim whether the animal can swim
*/
public Animal(String name,String color,String type,boolean canSwim){
this.name=name;
this.color=color;
this.type=type;
this.canSwim=canSwim;
}
String getColor() {
return color;
}
void setColor(String color) {
this.color = color;
}
String getName() {
return name;
}
void setName(String name) {
this.name = name;
}
String getType() {
return type;
}
void setType(String type) {
this.type = type;
}
boolean isCanSwim() {
return canSwim;
}
void setCanSwim(boolean canSwim) {
this.canSwim = canSwim;
}
/**
* String representation of this animal
* @return
*/
@Override
public String toString(){
return "[name="+name+",type="+type+",color="+color+",Can Swim="+(canSwim?"Yes":"No");
}
}