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 Cheetahint numTeeth, boolean spots, int weight
supernumTeeth spots, weight;
public String toStringString 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 ;
private boolean spots false;
private int weight ;
public Animalint numTeeth, boolean spots, int weight
this.setNumTeethnumTeeth;
this.setSpotsspots;
this.setWeightweight;
public int getNumTeeth
return numTeeth;
public void setNumTeethint numTeeth
this.numTeeth numTeeth;
public boolean getSpots
return spots;
public void setSpotsboolean spots
this.spots spots;
public int getWeight
return weight;
public void setWeightint weight
this.weight weight;
public static void mainString args
Scanner input new ScannerSystemin;
Get user informations
System.out.printlnEnter the number of teeth: ;
int numTeeth input.nextInt;
System.out.printlnDoes it have spots? truefalse;
boolean spots input.nextBoolean;
System.out.printlnEnter the weight: ;
int weight input.nextInt;
; Create an instance of the Lion class
Lion lion new LionnumTeeth spots, weight;
Display information about the lion
System.out.printlnliontoString;
input.close;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
