Multiple Inhertiance Using Interfaces
(see also the C++ version)
class Person
{
public Person () {}
public Person (String n) { name = n; }
public String toString() { return name; }
public String idString() { return null; }
String name;
}
class Student extends Person
{
public Student (String n, String i) { super(n); id = i; }
public String toString()
{
return super.toString() + " Today";
}
public String idString() { return id; }
String id;
}
class Employee extends Person
{
public Employee (String n, String i) { super(n); id = i; }
public String idString() { return id; }
String id;
}
interface EmployeeInterface
{
}
class StudentEmployee extends Student implements EmployeeInterface
{
public StudentEmployee (String n, String i) { super(n,i); }
// String idString() { return super.idString(); } // no longer needed
}
public class Students
{
public static void main(String arg[])
{
Student joan = new Student("Joan","100");
System.out.println(joan.toString());
StudentEmployee john = new StudentEmployee("John","123");
System.out.println(john.toString());
System.out.println(john.idString());
}
}