CollegeList Code

CollegeList.java

/*
 * Mark Hesser
 * HesserCAN 
 * [email protected]
 * www.hessercan.com
 */
package collegelist;
 
/**
 *
 * @author mark
 */
public class CollegeList {
 
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Person[] mark = new Person[4];
        mark[0] = new Person("Mark", "Hesser", "141 Tow Hill Rd", 16870, "814-777-7539");
        mark[1] = new CollegeEmployee("Mark", "Hesser", "141 Tow Hill Rd", 16870, "814-777-7539", "123-456-7890", 50000, "IT");
        mark[2] = new Faculty("Mark", "Hesser", "141 Tow Hill Rd", 16870, "814-777-7539", "123-456-7890", 50000, "IT", 1);
        mark[3] = new Student("Mark", "Hesser", "141 Tow Hill Rd", 16870, "814-777-7539", "IT", "3.4");
        for (Person person : mark){
            person.DisplayInfo();
        }
    }
 
}

CollegeEmployee.java

/*
 * Mark Hesser
 * HesserCAN 
 * [email protected]
 * www.hessercan.com
 */
package collegelist;
 
import javax.swing.JOptionPane;
 
/**
 *
 * @author mark
 */
public class CollegeEmployee extends Person {
   private final String SSN, Dept;
   private final double Salary;
 
   public CollegeEmployee(){
       super();
       SSN = setSSN();
       Salary = setSalary();
       Dept = setDept();
   }
   public CollegeEmployee(String fn, String ln, String st, int zip, String phone, 
           String ssn, double salary, String dept)
   {
       super(fn, ln, st, zip, phone);
       SSN = ssn;
       Salary = salary;
       Dept = dept;
   }
   private String setSSN(){
       return JOptionPane.showInputDialog(null, "SSN: ");
 
   }
   private double setSalary(){
       return Double.parseDouble(JOptionPane.showInputDialog(null, "Annual Salary: "));
   }
   private String setDept(){
       return JOptionPane.showInputDialog(null, "Department: ");
   }
   public String getSSN(){
       return SSN;
 
   }
   public double getSalary(){
       return Salary;
   }
   public String getDept(){
       return Dept;
   }
 
   @Override
   public void DisplayInfo(){ 
       JOptionPane.showMessageDialog(null, String.format("Name: %s %s \nAddress: %s \nZipcode: %d \nPhone: %s \n\nSSN: %s \nSalary: $%.2f \nDept: %s", 
               getFirstName(), getLastName(), getStreet(), getZipcode(), getPhoneNum(), SSN, Salary, Dept));
 
   }
}

Person.java

/*
 * Mark Hesser
 * HesserCAN 
 * [email protected]
 * www.hessercan.com
 */
package collegelist;
 
/**
 *
 * @author mark
 */
import javax.swing.*;
public class Person {
    private final String FirstName, LastName, Street, PhoneNum;
    private final int Zipcode; 
 
   public Person(){
        FirstName = setFirstName();
        LastName = setLastName();
        Street = setStreet();
        Zipcode = setZipcode();
        PhoneNum = setPhoneNum();
    }
    public Person(String fn, String ln, String st, int zip, String phone){
        FirstName = fn;
        LastName = ln;
        Street = st;
        Zipcode = zip;
        PhoneNum = phone;
    }
 
    private String setFirstName(){
        return JOptionPane.showInputDialog(null, "First Name:");
    }
    private String setLastName(){
        return JOptionPane.showInputDialog(null, "Last Name:");
    }
    private String setStreet(){
        return JOptionPane.showInputDialog(null, "Street Address:");
    }
    private int setZipcode(){
        return Integer.parseInt(JOptionPane.showInputDialog(null, "Zipcode:"));
    }
    private String setPhoneNum(){
        return JOptionPane.showInputDialog(null, "XXX-XXX-XXXX", "Phone Number:");
    }
 
    protected String getFirstName(){
        return FirstName;
    }
    protected String getLastName(){
        return LastName;
    }
    protected String getStreet(){
        return Street;
    }
    protected int getZipcode(){
        return Zipcode;
    }
    protected String getPhoneNum(){
        return PhoneNum;
    }
 
    public void DisplayInfo(){
        JOptionPane.showMessageDialog(null, String.format("Name: %s %s \nAddress: %s \nZipcode: %d \nPhone: %s", 
                FirstName, LastName, Street, Zipcode, PhoneNum));
    }
}

Faculty.java

/*
 * Mark Hesser
 * HesserCAN 
 * [email protected]
 * www.hessercan.com
 */
package collegelist;
 
import javax.swing.*;
 
/**
 *
 * @author mark
 */
public class Faculty extends CollegeEmployee{
    private boolean Tenured;
 
    public Faculty(){
       super();
       int option = JOptionPane.showConfirmDialog(null, "Is the Faculty Member Tenured?", "Faculty",                  
               JOptionPane.YES_NO_OPTION);
       Tenured = option == 0;
    }
    public Faculty(String fn, String ln, String st, int zip, String phone, 
           String ssn, double salary, String dept, int tenure)
    {
       super(fn, ln, st, zip, phone, ssn, salary, dept);
       Tenured = tenure == 0;
    }
    @Override
    public void DisplayInfo(){ 
        String isTenured;
        if (Tenured)
            isTenured = "Yes";
        else 
            isTenured = "No";
 
        JOptionPane.showMessageDialog(null, String.format("Name: %s %s \nAddress: %s \nZipcode: %d \nPhone: %s \n\nSSN: %s \nSalary: $%.2f \nDept: %s \n\nTenured: %s", 
               getFirstName(), getLastName(), getStreet(), getZipcode(), getPhoneNum(), getSSN(), getSalary(), getDept(), isTenured));
 
   }
}

Student.java

/*
 * Mark Hesser
 * HesserCAN 
 * [email protected]
 * www.hessercan.com
 */
package collegelist;
 
import javax.swing.*;
 
/**
 *
 * @author mark
 */
public class Student extends Person {
    private final String Major, GPA;
 
    public Student(){
        super();
        Major = setMajor();
        GPA = setGPA();
    }
    public Student(String fn, String ln, String st, int zip, String phone, String major, String gpa){
        super(fn, ln, st, zip, phone);
        Major = major;
        GPA = gpa;
    }
 
    private String setMajor(){
        return JOptionPane.showInputDialog(null, "Major: ");
    }
    private String setGPA(){
        return JOptionPane.showInputDialog(null, "X.X", "GPA: ");
    }
    public String getMajor(){
        return Major;
    }
    public String getGPA(){
        return GPA;
    }
 
    @Override
    public void DisplayInfo(){
        JOptionPane.showMessageDialog(null, String.format("Name: %s %s \nAddress: %s \nZipcode: %d \nPhone: %s \n\nMajor: %s \nGPA: %s", 
                getFirstName(), getLastName(), getStreet(), getZipcode(), getPhoneNum(), Major, GPA));
    }
}