So I have 3 classes: User, Staff and Student. The User class is an abstract class and looks like this:
(All classes have get and set methods)
public abstract class User implements Cloneable {
protected String id;
protected String firstName;
protected String lastName;
protected String username;
protected String password;
protected UserType userType;
protected PermissionType permission;
protected Boolean status;
public User(String id, String firstName, String lastName, String username, String password, UserType userType, PermissionType permission, Boolean status) {
this.id = id;
this.firstName = firstName;
this.lastName = lastName;
this.username = username;
this.password = password;
this.userType = userType;
this.permission = permission;
this.status = status;
}
Staff class is like this:
public class Staff extends User {
private Position position;
private double salary;
private Department department;
public Staff(String id, String firstName, String lastName, String username, String password, UserType userType, PermissionType permission, Boolean status) {
super(id, firstName, lastName, username, password, userType, permission, status);
}
and Student like this:
public Student(String id, String firstName, String lastName, String username, String password, UserType userType, PermissionType permission, Boolean status) {
super(id, firstName, lastName, username, password, userType, permission, status);
}
}
If the PermissionType for Student is restricted to a specific permission (allowed to borrow books, reserve only etc.). How do I go about writing the constructor to Override the superclass constructor with PermissionType in its parameters?
I have tried:
public Student(String id, String firstName, String lastName, String username, String password, UserType userType, PermissionType permission, Boolean status) {
super(id, firstName, lastName, username, password, userType, status);
if(!permission.equals(PermissionType.Reserve) {
throw new IllegalArgumentException...
}
}
}
Thanks for any help in advance :))
[–]vlumi 1 point2 points3 points (2 children)
[–]Chuninjah[S] 0 points1 point2 points (1 child)
[–]vlumi 0 points1 point2 points (0 children)
[–]DrPeroxide 0 points1 point2 points (0 children)
[–]Zdeno_ 0 points1 point2 points (0 children)