Skip to main content
deleted 1 character in body
Source Link

Welcome to CodeReview.se andCode Review and thanks for sharing your code.

Your class OfficialAddress extends your class User. This does not look right.

By extending a class you declare an is a relationship. But an address never is a user.

instead a user has a Address. In OOP this is expressed by giving the owner (class User) a property of the other class (OfficialAddress):

public class OfficialAddress { // no extending here
  // ...
}

public class User{
  private OfficialAddress officialAddress;
  // ...
  public User(String firstName, String lastName, int idNumber, String email, OfficialAddress, officialAddress) {
        this.firstName = firstName;
        this.lastName = lastName;
        this.idNumber = idNumber;
        this.email = email;
        this.officialAddress = officialAddress;
    }
} 

Welcome to CodeReview.se and thanks for sharing your code.

Your class OfficialAddress extends your class User. This does not look right.

By extending a class you declare an is a relationship. But an address never is a user.

instead a user has a Address. In OOP this is expressed by giving the owner (class User) a property of the other class (OfficialAddress):

public class OfficialAddress { // no extending here
  // ...
}

public class User{
  private OfficialAddress officialAddress;
  // ...
  public User(String firstName, String lastName, int idNumber, String email, OfficialAddress, officialAddress) {
        this.firstName = firstName;
        this.lastName = lastName;
        this.idNumber = idNumber;
        this.email = email;
        this.officialAddress = officialAddress;
    }
} 

Welcome to Code Review and thanks for sharing your code.

Your class OfficialAddress extends your class User. This does not look right.

By extending a class you declare an is a relationship. But an address never is a user.

instead a user has a Address. In OOP this is expressed by giving the owner (class User) a property of the other class (OfficialAddress):

public class OfficialAddress { // no extending here
  // ...
}

public class User{
  private OfficialAddress officialAddress;
  // ...
  public User(String firstName, String lastName, int idNumber, String email, OfficialAddress, officialAddress) {
        this.firstName = firstName;
        this.lastName = lastName;
        this.idNumber = idNumber;
        this.email = email;
        this.officialAddress = officialAddress;
    }
} 
Source Link

Welcome to CodeReview.se and thanks for sharing your code.

Your class OfficialAddress extends your class User. This does not look right.

By extending a class you declare an is a relationship. But an address never is a user.

instead a user has a Address. In OOP this is expressed by giving the owner (class User) a property of the other class (OfficialAddress):

public class OfficialAddress { // no extending here
  // ...
}

public class User{
  private OfficialAddress officialAddress;
  // ...
  public User(String firstName, String lastName, int idNumber, String email, OfficialAddress, officialAddress) {
        this.firstName = firstName;
        this.lastName = lastName;
        this.idNumber = idNumber;
        this.email = email;
        this.officialAddress = officialAddress;
    }
}