I am having trouble getting the student portion of my test program to work.
this is the student class file:
and this is the test program.
this is the student class file:
//java 2 11.2
//by jeff taddei
//create student class
class Student extends Person {
private static int FRESHMAN = 1;
private static int SOPHOMORE = 2;
private static int JUNIOR = 3;
private static int SENIOR = 4;
private int status;
public Student() {
}
public Student(int status) {
this.status = status;
}
public Student(String name, String address, String phone, String email, int status){
super(name, address, phone, email);
this.status = status;
}
public String toString() {
return "Student: "+ this.getName() + "\nStatus: " + status + "\n" +
this.getAddress() + this.getphoneNumber() + this.getEmail();
}
}
and this is the test program.
//java 2 11.2
//by jeff taddei
//create Person test program
import javax.swing.JOptionPane;
public class TestPerson {
public static void main(String[] args) {
Person[] person = new Person[5];
person[0] = new Person(" Jeff Taddei ", "511 North 5th St. ", " 910-233-1234 ", " taddej@yahoo.com ");
person[1] = new Student(" Big Bird ", "223 Seasame St. ", " 910-222-3456 ", " bbird@yahoo.com ", "Freshman");
person[2] = new Employee( " Johnny Walker ", "55 Scotch St. ", " 910-555-5555 ", " jwalker@sip.com ", "9am-5pm", 1000);
MyDate date2 = new MyDate(1, 11, 2012);
person[3] = new Faculty(" Billy Bob ", "23 Red St. ", " 910-333-1235 ", " bbob@holler.com ", " 9am-5pm ", 2);
person[4] = new Staff(" Barney Rubble ", "10 BC St. ", " 910-333-4569 ", " brubble@stone.com ", " Janitor ");
for (int i=0; i<person.length; ++i){
if (person[i] instanceof Person){
JOptionPane.showMessageDialog (null, ((Person)person[i]).toString(), "Personal Information", JOptionPane.INFORMATION_MESSAGE);
}
else if (person[i] instanceof Student){
JOptionPane.showMessageDialog (null, ((Student)person[i]).toString(), "Personal Information", JOptionPane.INFORMATION_MESSAGE);
}
else if (person[i] instanceof Employee){
JOptionPane.showMessageDialog (null, ((Employee)person[i]).toString(), "Personal Information", JOptionPane.INFORMATION_MESSAGE);
}
else if (person[i] instanceof Faculty){
JOptionPane.showMessageDialog (null, ((Faculty)person[i]).toString(), "Personal Information", JOptionPane.INFORMATION_MESSAGE);
}
else if (person[i] instanceof Staff){
JOptionPane.showMessageDialog (null, ((Staff)person[i]).toString(), "Personal Information", JOptionPane.INFORMATION_MESSAGE);
}
}
}
}