Answer to Question #249545 in Java | JSP | JSF for Bonnie

Question #249545

CreateabaseclasscalledAnimalwhichhas2classfields.ThefirstfieldholdsanintegerIDtagfora numberthatazoousestocataloguetheiranimals&thesecondfieldholdsastringcalledspecies. FromtheAnimalclass,derive2classesOneisBird&theotherReptile.Birdclasshasanadditional classfieldcalledcolourwhichholdsthe colour of the birds feathers(int – 1=grey, 2=white, 3=black).reptile class has an additional class field called bloodTemp which hold the reptiles temperature of their blood (double).You need to instantiate two 2 objects.bird object will be called brd.reptile object called rept.Input values for the bird’s IDtag,species & feather colour(int) & for the reptile’s IDtag number,species & bloodTemp.Override the Animal class’s input & output methods.Each derived class must have its own constructor.Write methods to input & output values to the class fields for all classes & then print out the values of the bird & reptile class fields with labels identifying the values. 


1
Expert's answer
2021-10-10T16:56:33-0400
public class Animal {
  private int ID;
  private String species;

  public Animal(int id, String s) {
    this.ID = id;
    this.species = s;
  }

 public void setID(int id) {
  this.ID = id;
 }
 public void setS(String s) {
  this.species = s;
 }
 public int getID() { return ID; {
 public String getSpecies() { return species; }
}

class Bird extends Animal {
  public Bird(int id, String s) {
    super(id, s);
  }
}

class Reptile extends Animal {
  public Reptile(int id, String s) {
    super(id, s);
  }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS