I need to write an Array List of Pets. An item list is either a Dog or a Cat. For each pet enter a name and type (C for cat or D for dog). Input should stop when the word STOP is entered for the name. I need to also have the Dog class to include an instance variable for weight(double) and Cat to include an instance variable coatColor(string). The user will basically enter name and type. If it is cat they input its coat color. If it is a dog input its weight for each pet. Output into a list.
This is what I have so far I need help finishing this and the main:
import java.io.*;
import util.*;
class Pet {
public static void main(String[ ] args) throws IOException {
class Cat extends Pet {
Cat [ ] cat = new Cat[2];
public String coatColor(), name();
public char type("c");
}
class Dog extends Pet{
Dog[ ] dog = new Dog[2];
public String name();
public char type("d");
public double weight();
}
public int getWeight( ) {
return weight;
}
public char getType( ) {
return type;
}
public String getName( ), getCoatColor( ) {
return name, coatColor;
}
public void setWeight( double weight) {
weight = newWeight;
}
public void setType(char type) {
type = newType;
}
public void setName(String name), setCoatColor(String coatColor) {
name = newName
coatColor = newCoatColor;
}
for (int i = 0; i < pet.length; i ++);