i have a superclass Dinosaur with only one subclass Tyrano
i have Dinosaur with these attributes:
public Dinosaur(String name, String size, String movement, String diet, String terainType){
...
//i've already made the setters and getters along with some helper functions
}
and i have Tyrano with 2 additional attributes which are teeth and hobby
public Tyrano(String name, String size, String movement, String diet, String terainType, int teeth, String hobby){
...
//made setters and getters with some helper functions
}
now in my driver program i want to make an array type Dinosaur that will accept multiple subclasses of Dinosaur one of them which is the subclass Tyrano i don't know if its possible but my instructor said it is so here's what i did, this is on the main:
Dinosaur[] dinoList = new Dinosaur[9];
dinoList[0] = new Tyrano("Gary", "Large", "other dino Meat", "Land", 30, "singing");
int teeth = dinoList[0].getTeeth();
String hobby = dinoList[0].getHobby();
...//i also called the helper functions that were in Tyrano
it gets an error:
error: cannot find symbol
dinoList[0].getTeeth();
^
error: cannot find symbol
dinoList[0].getHobby();
^
...//along with same errors with the helper functions that were in Tyrano
...//it also happens when i call setters that were unique for the subclass Tyrano
and i don't know why it's doing this, i've double checked and i have no syntactical errors and i've already defined the helper functions, also those getters and setters, but there's no problem for the common ones which are found in the superclass Dinosaur