The goal at this point is just to find out why this code isn't compiling. The class below creates a new instance of 'K12Student' according to certain conditions, that class being a super class which extends to three subclasses which define different types of students. Each subclass contains unique instance variables and their get and set methods. The class is currently as follows:
import java.util.*; //Create New arraylist for client instances public class StudentInput { private InputHelper input; private ArrayList students; public void run() { studentInfoEntry(); } //Assign data to instances of client public void studentInfoEntry() { students = new ArrayList(); input = new InputHelper(); String studentIDString = ""; int studentID = 0; String studentName = ""; String schoolName = ""; String gradeLevelString = ""; int gradeLevel = 0; String validateAddNewStudent = ""; while (true) { studentIDString = input.getUserInput("Enter student ID number."); studentID = Integer.parseInt(studentIDString); studentName = input.getUserInput("Enter student name."); schoolName = input.getUserInput("Enter school name."); gradeLevelString = input.getUserInput("Enter grade level."); gradeLevel = Integer.parseInt(gradeLevelString); if (gradeLevel >= 0 && gradeLevel <= 12) { if (gradeLevel >= 0 && gradeLevel <= 4) { String readingLevelString = ""; int readingLevel = 0; String classSection = ""; readingLevelString = input.getUserInput("Enter reading level."); readingLevel = Integer.parseInt(readingLevelString); classSection = input.getUserInput("Enter class section."); /*K12Student*/ PrimaryStudent newStudent = new PrimaryStudent(); newStudent.setStudentID(studentID); newStudent.setStudentName(studentName); newStudent.setSchoolName(schoolName); newStudent.setReadingLevel(readingLevel); newStudent.setClassSection(classSection); } if (gradeLevel >= 5 && gradeLevel <= 8) { String lunchHourString = ""; int lunchHour = 0; String homeroomTeacher = ""; lunchHourString = input.getUserInput("Enter lunch hour."); lunchHour = Integer.parseInt(lunchHourString); homeroomTeacher = input.getUserInput("Enter homeroom teacher."); /*K12Student*/ MiddleStudent newStudent = new MiddleStudent(); newStudent.setStudentID(studentID); newStudent.setStudentName(studentName); newStudent.setSchoolName(schoolName); newStudent.setLunchHour(lunchHour); newStudent.setHomeroomTeacher(homeroomTeacher); } if (gradeLevel >= 9 && gradeLevel <= 12) { String GPAString = ""; int GPA = 0; String collegeChoice = ""; GPAString = input.getUserInput("Enter reading level."); GPA = Integer.parseInt(GPAString); collegeChoice = input.getUserInput("Enter class section."); K12Student newStudent = new HighStudent(); newStudent.setStudentID(studentID); newStudent.setStudentName(studentName); newStudent.setSchoolName(schoolName); newStudent.setReadingLevel(readingLevel); newStudent.setClassSection(classSection); } students.add(newStudent); validateAddNewStudent = input.getUserInput("Enter another student? (y/n)"); if (!validateAddNewStudent.equals("y")) { break; } }else{ System.out.println("Grade level must be from 0-12."); } } } } Also, the instantiation of each new middle school and elementary school student originally read like that of the high school student (K12Student newStudent = new HighStudent;), but I had more issues compiling with that format. The compiler errors are as follows:
javac K12StudentTestDrive.java
./StudentInput.java:97: error: cannot find symbol newStudent.setReadingLevel(readingLevel); ^ symbol: variable readingLevel location: class StudentInput ./StudentInput.java:98: error: cannot find symbol newStudent.setClassSection(classSection); ^ symbol: variable classSection location: class StudentInput ./StudentInput.java:100: error: cannot find symbol students.add(newStudent); ^ symbol: variable newStudent location: class StudentInput 3 errors Thanks in advance for any feedback.