Best writers. Best papers. Let professionals take care of your academic papers

Order a similar paper and get 15% discount on your first order with us
Use the following coupon "FIRST15"
ORDER NOW

can’t seem to figure out why my program won’t run.

 can’t seem to figure out why my program won’t run.  I am not even sure if I have the Animal newInstance method

written correctly in my Animal class.  I am new to Java and am struggling with this.  I have attached what I have done so far.  Here is my Mammal class (since I couldn’t attach it). Can you help with cleaning up my code so that it will run?  And help me with the Test class? I have not been able to figure out how to do that.

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package animalstuff;

/**
*
* @author
*/
public class Mammal extends Animal {
String integument = “hair”;

@Override
public String movement (boolean fast){
if (fast == true){
return “I run.”;
} else {
return “I walk.”;
}
}

public class Cow extends Mammal {
public Cow(){
Cow.kind = “cow”;
}

public void newCow(){
}

@Override
public String sound(){
return “‘Moo Moo'”;
}
}
public class Horse extends Mammal {
public Horse(){
Horse.kind = “horse”;
}

public void newHorse(){
}

@Override
public String sound(){
return “‘Hee Haw'”;
}
}
public class Dog extends Mammal {
public Dog(){
Dog.kind = “dog”;
}

public void newDog(){
}

@Override
public String sound(){
return “‘Woof Woof'”;
}
}
public class Cat extends Mammal {
public Cat(){
Cat.kind = “cat”;
}

public void newCat(){
}

@Override
public String sound(){
return “‘Meow Meow'”;
}
}
}//END OF MAMMAL CLASS

/** To change this license header, choose License Headers in Project Properties.* To change this template file, choose Tools | Templates* and open the template in the editor.*/package animalstuff;/**** @author*/public class Animal {public static String kind;public static String integument;//a no-argument constructor that prevents users from creating a “plain”animalprotected Animal() {}//Method that returns one of two stringspublic String movement(boolean fast) {if (fast == true){return “I run on four legs”;} else {return “I walk on four legs”;}}//returns the sound the animal makespublic String sound() {return “”;}//takes the desired kind of animal, calls the constructor for a particularkind of animal & returns the resultpublic Animal newInstance(String kind){if (kind.isEmpty())return null;if (kind.equalsIgnoreCase(“Bird”))return new Bird();else if (kind.equalsIgnoreCase(“Mammal”))return new Mammal();else return null;}//a print method – when called it will print out the info about the animalpublic void print() {System.out.println(“I am a ” + Animal.kind);System.out.println(“When I go slowly, ” + this.movement(false));System.out.println(“When I go fast, ” + this.movement(true));System.out.println(“The sound I make is ” + this.sound());}}
Background image of page 1
 
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"