Question: This is another class that extends from the Animal class and it asking for this requirements, but i do not think they are any how

This is another class that extends from the Animal class and it asking for this requirements, but i do not think they are any how met, can you please review it and help me accordingly:
Follow these steps:
Modify the existing Animal.java file for this task.
Create a class called Cheetah that:
Inherits from the Animal class.
Makes use of at least one static field which needs to have a static
setter and getter.
Contains a constructor.
Contains a toString() method.
Has an array as one of its fields.
Create an application class. Within the main method, create a Cheetah
object and print out (to the screen) the details that describe this object.
Compile, save and run your file.
class Cheetah extends Animal {
public Cheetah(int numTeeth, boolean spots, int weight){
super(numTeeth, spots, weight);
}
public String toString(String cheetah){
String output = "Number of Teeth: "+ getNumTeeth();
output +="
Does it have spots?: "+ getSpots();
output +="
How much does it weigh: "+ getWeight();
output +="
Cheetah";
return output;
}
}
import java.util.Scanner;
public class Animal {
private int numTeeth =0;
private boolean spots = false;
private int weight =0;
public Animal(int numTeeth, boolean spots, int weight){
this.setNumTeeth(numTeeth);
this.setSpots(spots);
this.setWeight(weight);
}
public int getNumTeeth(){
return numTeeth;
}
public void setNumTeeth(int numTeeth){
this.numTeeth = numTeeth;
}
public boolean getSpots(){
return spots;
}
public void setSpots(boolean spots){
this.spots = spots;
}
public int getWeight(){
return weight;
}
public void setWeight(int weight){
this.weight = weight;
}
public static void main(String[] args){
Scanner input = new Scanner(System.in);
// Get user informations
System.out.println("Enter the number of teeth: ");
int numTeeth = input.nextInt();
System.out.println("Does it have spots? (true/false)");
boolean spots = input.nextBoolean();
System.out.println("Enter the weight: ");
int weight = input.nextInt();
; // Create an instance of the Lion class
Lion lion = new Lion(numTeeth, spots, weight);
// Display information about the lion
System.out.println(lion.toString());
input.close();
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!