Trying to call a method from a subclass using the super class's object in a whole different class

Viewed 28

This is my method. Type schedule is an array list using the Class Activity. However, the method getName and getSection are both in Activities subclass and a.getName(); and a.getSection() are both failing. Hopefully someone can help me!

public String[][] getScheduledActivities() {
    String [][] scheduledCourse;
    if (schedule.size() == 0) {
        scheduledCourse = new String[0][0];
    } else {
        scheduledCourse = new String[schedule.size()][3];
        for (int i = 0; i < schedule.size(); i++) {
            Activity a = schedule.get(i);
            scheduledCourse[i] = a.getShortDisplayArray();
            scheduledCourse[i][0] = a.getName();
            scheduledCourse[i][1] = a.getSection();
            scheduledCourse[i][2] = a.getTitle();                   
        }
    }
    return scheduledCourse;
}
0 Answers
Related