Encapsulation Example, Michael Carrera - ZachZimmerman/preAPCS-4th-1415 GitHub Wiki

Encapsulation is way of making certain function or methods private so the only apply to certain classes.

HoobaDooba

EX:

public class Account{

private int password;

private String username;

private String profilepic;

public Account ( int password, String username, String profilepic) {

this.password = password;

this.username = username;

this.profilepic = profilepic;

}

public int getPassword() {

return password;

}

public void setPassword(int password){

this.password = password;

}

public String getUsername() {

return username;

}

public void setUsername(string username){

this.username = username;

}

public String getProfilepic() {

return profilepic;

}

public void setProfilepic(string profilepic){

this.profilepic = profilepic

}