Answer to Question #246857 in Java | JSP | JSF for Princess

Question #246857
Create a base class called "Animal" which has two (2) class fields. The first field holds an integer "IDtag" for a number that a zoo uses to catalogue their animals and the second field holds a string called "species."

From the Animal class, derive two (2) classes. One is called "Bird" and the other "Reptile". E.g. Species could be (for the Bird class) ostrich, dove, chicken etc. and (for the Reptile class) lizard, snake, bearded dragon etc.

The Bird class has an additional class field called "colour" which holds the colour of the birds. feathers * (int - 1 = gre) , 2-white, 3=black) . The reptile class has an additional class field called "bloodTemp" which hold the reptile's temperature of their blood (double).

You need to instantiate two (2) objects. The bird object will be called "brd" and the reptile object

called "rept."

Input values for the bird's IDtag, species and feather colour (int) and for the reptile's IDtag number, species and bloodTemp.
1
Expert's answer
2021-10-05T23:13:42-0400


public class Main
{
	public static void main(String[] args) {
		Bird brd=new Bird(123,"ostrich","black");
		Reptile rept=new Reptile(145,"lizard",45.75);
	}
}


class Animal{
    private int IDtag;
    private String species;
    
    public Animal(int id, String s){
        IDtag=id;
        species=s;
    }
    
    
}


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


class Reptile extends Animal{
   private double bloodTemp;
   public Reptile(int id,String s, double b){
       super(id, s);
       bloodTemp=b;
   }
   
}

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