So what I am trying to do is this:
Write a User class
A User:
- has a username e.g 'fj3'
- has a userType which can be: 'user', 'editor' or 'admin'
- has a name e.g 'Francis'
- has a constructor which takes the username, userType and name as parameters
- has a getUsername() method
- has a getUserType() method
- has a getName() method
- has a setUserType() method which takes one of the user types as a parameter
My code so far:
public class User{
public String id;
public String userPermissions;
public String actualName;
public User(String username, String userType, String name){
id = username;
userPermissions = userType;
actualName= name;
}
public String getUsername(){
return id;
}
public String getUserType(){
return userPermissions;
}
public String getName(){
return actualName;
}
public enum UserType{
admin, editor, user;
}
public void setUserType(String input){
userPermissions = input;
}
}
What do I need to do to get this to work? I do not know how to make it so the only usertypes that can be chosen are admin, editor or user.