Vote count:
0
I have an interface:
public interface IUser {
public boolean login();
}
and two classes that implement this interface:
public class UserA implements IUser{
public boolean login() {
System.out.println("login");
}
public void update() {
System.out.println("update");
}
}
public class UserB implements IUser {
public boolean login() {
System.out.println("login");
}
public void delete() {
System.out.println("delete");
}
}
My question is if I create a user:
IUser user = new UserA();
user object doesn't have access to update() however it is recommended to create object using interface, I was wondering if there is a best practice or design pattern I can use (rather than casting it)?
asked 28 secs ago
Aucun commentaire:
Enregistrer un commentaire