I have a Name Class:
public class Name {
// Instance Variables
private String title;
private String firstName;
private String surname;
}
A Person Class:
public abstract class Person {
protected Name name;
protected String phoneNumber;
Default Constructor
public Person(){
name=new Name();
phoneNumber=null;
}
However, problem is in my employee class when I want to read in a new employee from keyboard input:
public class Employee extends Person implements Serializable{
private Date dob;
private double salary;
private Date startDate;
private int number;
private static int nextNumber=1;
private final double MAX_SALARY = 100000;
private final double INCREMENT = 500;
// Default Constructor
public Employee(){
super(); // Not needed
dob=new Date();
salary=0.0;
startDate=new Date();
}
// Initialization Constructor
public Employee(String t, String fN, String sn, String phoneNo, int d, int m, int y,
double salary, int sD, int sM, int sY){
// Call super class constructor
super(t, fN, sn, phoneNo);
// And then initialise Employees own instance variables
dob=new Date(d,m,y);
this.salary=salary;
startDate=new Date(sD,sM,sY);
}
Set number to static nextNumber before incrementing nextNumber number = nextNumber++;
public void read(){
Scanner kbInt = new Scanner(System.in); // Scanner is serializable
Scanner kbString = new Scanner(System.in);
System.out.println("EMPLOYEE DETAILS ==>");
System.out.print("NUMBER : ");number=kbInt.nextInt();
System.out.print("Title : ");name=kbString.nextLine();
System.out.print("FIRSTNAME : ");firstName=kbString.nextLine();
System.out.print("SURNAME : ");surname=kbString.nextLine();
System.out.print("PHONE NO : ");phoneNumber=kbString.nextline();
System.out.print("D.O.B. : ");dob=kbInt.nextInt();
}
How do I read in a new employee eg (Title, firstName & surname) and dob (12 11 95)?