/** * @author Java Student */ public class Fruit { String name; String[] color = new String[10]; String image; int calories; /** Creates a new instance of Fruit */ public Fruit(String name,String[] color,String image,int calories) { this.name = name; if (color.length <= 10 ) { System.arraycopy(color,0,this.color,0,color.length); } else { System.arraycopy(color,0,this.color,0,10); } this.image = image; this.calories = calories; } public Fruit(String name,String[] color,int calories) { this.name = name ; if (color.length <= 10 ) { System.arraycopy(color,0,this.color,0,color.length); } else { System.arraycopy(color,0,this.color,0,10); } this.image = "No Image" ; this.calories = calories ; } public Fruit(String name,String[] color) { this.name = name ; if (color.length <= 10 ) { System.arraycopy(color,0,this.color,0,color.length); } else { System.arraycopy(color,0,this.color,0,10); } this.image = "No Image" ; } public String getName() { return this.name; } public String[] getColor() { return this.color; } public String getImage() { return this.image; } public int getCalories() { return this.calories; } public void setName(String name){ this.name = name; } public void setColor(String[] color){ if (color.length <= 10 ) { System.arraycopy(color,0,this.color,0,color.length); } else { System.arraycopy(color,0,this.color,0,10); } } public void setImage(String image){ this.image = image; } public void setCalories(int calories){ this.calories = calories; } public void showDetails() { System.out.println("Fruit Name: " + this.name) ; System.out.println("Fruit Colors: " ) ; for(int i=0;i