public class InterfaceTestProg {
public static void main (String [] args) {
Person2 p = new Person2 ();
p.setName ("David");
p.setMatricel ("1234567");
p.setZIP ("1234567");
p.setStreet ("Road17777777");
p.printAll ();
}
public interface PersonA {
void setMatricel (String matricel);
String getMatricel ();
}
public interface PersonB {
void setName (String name);
String getName ();
}
public interface Person extends PersonA, PersonB {
void setZIP (String name);
String getZIP ();
}
public static class Person1 {
public String street;
Person1 (String street) {
this.street = street;
}
Person1 () {
this.street = null;
}
String getStreet () {
return street;
}
void setStreet (String street) {
this.street = street;
}
}
public static class Person2 extends Person1 implements Person {
String matricel;
String name;
String ZIP;
Person2 (String matricel, String name, String ZIP, String street) {
this.matricel = matricel;
this.name = name;
this.ZIP = ZIP;
this.street = street;
}
Person2 () {
this.matricel = null;
this.name = null;
this.ZIP = null;
this.street = null;
}
@Override
public void setZIP (String ZIP) {
this.ZIP = ZIP;
}
@Override
public String getZIP () {
return this.ZIP;
}
@Override
public String getMatricel () {
return this.matricel;
}
@Override
public void setMatricel (String matricel) {
this.matricel = matricel;
}
@Override
public String getName () {
return this.name;
}
@Override
public void setName (String name) {
this.name = name;
}
public void printAll () {
System.out.println (name);
System.out.println (matricel);
System.out.println (ZIP);
System.out.println (street);
}
}
}