I am having a problem with seeing subclass attributes in an ArrayList.
Here's some snippets of the main parts of my code that matter here.
private ArrayList<Person> people = new ArrayList<Person>;
abstract class Person {
String fName;
String lName;
}
public class Employee extends Person {
protected int empID;
}
public class Client extends Person {
protected int clientID;
}
When using a for loop to search by clientID, I am getting
Enterprise.java:134: cannot find symbol symbol : variable clientID location: class Person
I have tried with and without instanceof Client on the for loop. I have also tried using Client instead of Person in the for loop parameters.
for(Person x : people) {
if(x.clientID == cid) {
System.out.println(x);
}
Before turning these into subclasses I had them in an ArrayList of their own kind and everything worked flawlessly.
Any help would be greatly appreciated!
xtoClientbefore attempting thex.clientID.. something like((Client)x).clientID == cid