title: Java Inheritance and Polymorphism Program
body: <p>I am new to Java and have most likely made a stupid mistake on my code.  In particular, I am having problems with the main arguments, asking for and saving scanner objects to link to the other subclasses.  I believe that the Person, Student, Employee, Faculty, and Staff portions are correct but I cannot figure out the Driver portion. Below is the homework problem.  Thank you in advance for any help or advice!</p>
  
  <p>HOMEWORK PROBLEM:
  Design a class named  Person and its two subclasses, Student and Employee. Make Faculty and Staff subclasses of Employee.</p>
  
  <p>A Person object  has a name , address, phone number, and email address (all Strings ). </p>
  
  <p>A Student has a class  status (freshman, sophomore, junior, or senior). Define the status as a final String  variable .</p>
  
  <p>An Employee has an office number , salary (both ints ), and a date hired. Use the MyDate class  defined below to create an object  for date hired:</p>
  
  <pre><code>class  MyDate{
  private  String  date; //date in the form mm/dd/yy
  
  public MyDate(String  date){
  this.date = date;
  }
  
  public String  getDate(){
  return date;
  }
  }
  </code></pre>
  
  <p>A Faculty object  has office hours and a rank (both Strings ), while a Staff object  has a title (as a String ). </p>
  
  <p>For the Student, Faculty, and Staff classes, create toString methods  that store  information about the object  (in the format shown in the examples below).</p>
  
  <p>Test your classes in a Driver class  (within the same file) that asks the user what type  of object  they'd to create as well as what information they'd like it to have.
  The program  then uses the object 's toString method  to print information about that object .
  Sample Run #1</p>
  
  <p>Enter 
  1)To create a student 
  2)To create an employee:  1<br>
  Enter  name :  Walter D. Graham<br>
  Enter address:  4737 Stadium Drive Whitinsville, MA 01588<br>
  Enter phone number:  508-266-2108<br>
  Enter email:  walterdgraham@university.edu<br>
  Enter student's status:  Junior<br>
  Student: Walter D. Graham 
  Status: Junior 
  Address: 4737 Stadium Drive Whitinsville, MA 01588 
  Phone Number: 508-266-2108 
  Email Address: walterdgraham@university. edu
  Sample Run #2</p>
  
  <p>Enter 
  1)To create a student 
  2)To create an employee:  2<br>
  Enter  name :  Kimberly D. Davis<br>
  Enter address:  795 University Hill Road Decatur, IL 62522<br>
  Enter phone number:  217-519-6747<br>
  Enter email:  kimdavis@school.edu<br>
  Enter 
  1)To create a faculty member 
  2)To create a staff member:  1<br>
  Enter office number:  724<br>
  Enter salary:  84101<br>
  Enter date hired (mm/ dd/ yy):  06/12/92<br>
  Enter office hours:  5-7pm, Mon-Thu<br>
  Enter rank:  Adjunct Professor<br>
  Faculty: Kimberly D. Davis 
  Rank: Adjunct Professor 
  Salary: $84101 
  Date Hired: 06/12/92 </p>
  
  <p>Office Hours: 5-7pm, Mon-Thu 
  Office: 724 
  Address: 795 University Hill Road Decatur, IL 62522 
  Phone Number: 217-519-6747 
  Email: kimdavis@school. edu</p>
  
  <p>DRIVER PORTION THAT I WROTE:</p>
  
  <pre><code>package person;
  import java.util.Scanner;
  public class Driver {
  //Testing
  
  public static void main(String[] args) {
  
  int studentOrEmployee;
  int facultyOrStaff;
  
  Scanner input = new Scanner(System.in);
  
  System.out.println("Enter");
  System.out.println("1)To create a student:");
  System.out.print("2)To create and employee: ");
  studentOrEmployee= input.nextInt();
  
  System.out.print("\n Enter name: ");
  Person name = input.next();
  System.out.print("\n Enter address: ");
  Person address = input.nextString();
  System.out.print("\n Enter phone number: ");
  Person phone = input.nextString();
  System.out.print("\n Enter email ");
  Person email = input.nextString();
  
  if (studentOrEmployee==1) {
  System.out.print("\n Enter student’s status: ");
  Person classStanding = input.nextString();
  System.out.println(student.toString() + "\n");
  }
  
  else if ( studentOrEmployee==2) {
  
  facultyOrStaff= input.nextInt();
  if (facultyOrStaff==1) {
  System.out.print("\nEnter office number: ");
  Person office = input.nextInt();
  System.out.print("\nEnter salary");
  Person salary = input.nextInt();
  System.out.print("\nEnter date hired: ");
  Person dateHired = input.next();
  System.out.print("\nEnter office hours: ");
  Person hours = input.nextString();
  System.out.print("\nEnter rank: ");
  Person rank = input.nextString();
  System.out.println(faculty.toString() + "\n"); 
  }   
  else if (facultyOrStaff==2) {
  System.out.print("\nEnter office number: ");
  System.out.print("\nEnter office title: ");
  Person title = input.nextString();
  System.out.println(staff.toString() + "\n");
  }
  }
  Person person = new Person(name,address, phone, email);
  Person student = new Student(name, classStanding, address, phone, email);
  Person employee = new Employee(name, address, phone, email, office, salary, dateHired);
  Person faculty = new Faculty(name, rank, salary, dateHired, hours, address, phone, email, office);
  Person staff = new Staff(name, title, address, phone, email, office, salary, dateHired);
  }
  }
  </code></pre>