The problem is on my second switch case 1: I will put the "arrayEmployees[0]." but it doesn't see my methods in the superclass PersonData or the subclass personLocation. My understanding of polymorhpism is a bit shady as well as the internal "Object" possibility as I just began learning about these so perhaps I am referencing them wrong.
I was given these instructions:
Design a new class called PersonTest with a main method that defines a PersonData object and a PersonLocation object (both without arguments) and two more objects with arguments and store all the objects in an Array for retrieval and modification of instantiated objects (i.e. Array of Objects).
My Actual Code
package lab5;
import java.util.InputMismatchException;
import java.util.Scanner;
public class PersonTest
{
public static void main(String args[])
{
Scanner input = new Scanner(System.in);
PersonLocation personLocation = new PersonLocation();
PersonData personData = new PersonData();
PersonLocation personLocationOverLoaded = new PersonLocation("Hamilton");
PersonData personDataOverloaded = new PersonData("Stirling", "905-567-7656");
Object[] arrayEmployees = new Object[4];
arrayEmployees[0] = personLocation;
arrayEmployees[1] = personLocationOverLoaded;
arrayEmployees[2] = personData;
arrayEmployees[3] = personDataOverloaded;
int user = 0;
int menu = 0;
// Get input here, put into variable "user"
switch(user)
{
case 1:
System.out.print("Printing Object Information With Given Values\n\n\t");
arrayEmployees[0]. //Issue
}
}//End Main Method
}//End Class PersonTest
What is Supposed to Happen: I am suppose to be able to reference from my array as shown above (arrayEmployees[0].) and have my methods show up for that particular class.