we have homework in Java to do some users, contracts, and some API. We should create a user with some information about him and one of that information should be address (one where he live and one where post should come) But I am not sure if I did it correctly.
I create a package called user inside which i created User.class
package xxx;
import java.util.List;
public abstract class User {
private int ID;
private String firstName;
private String lastName;
private int idNumber;
private String email;
private String officialAddress;
private String postAddress;
private List contracts;
public User(String firstName, String lastName, int idNumber, String email) {
this.firstName = firstName;
this.lastName = lastName;
this.idNumber = idNumber;
this.email = email;
}
public String getFullName() {
return firstName + " " + lastName;
}
}
and OfficialAddress.class
package xxx;
public class OfficialAddress extends User {
private int zipcode;
private String region;
private String streetName;
private int streetNumber;
public OfficialAddress(String firstName, String lastName, int idNumber, String email) {
super(firstName, lastName, idNumber, email);
}
}
I just want to ask if is good practice to do it like this or if it should be different. We just cant use nested classes and static methods. Thanks for review.