Here's a suggestion, I haven't tailored it to your needs exactly (sorry about that). It's written in pseudo-code so it's easy to read.
Feel free to shoot this down, I'm looking for flaws.
class User
----------
string name
string address
string username
string password
struct userTypes //This contains a structure of different user types for
this user
//Method to check if user is of a particular type
boolean isUserType(_typeName){
if (userTypes.keyExists(_typeName))
return true
else
return false;
}
//Method that returns a reference to the userType
UserType getUserType(_typeName){
return userTypes._typeName
}
//Add user type to structure
boolean addUserType(_type){
typeName = _type.typeName
userTypes.typeName = _type
}
class UserType
--------------
string typeName //super class
class Student extends UserType
------------------------------
//student properties and methods
class Staff extends UserType
------------------------------
//common properties and methods for Faculty and Teaching Assistants
class Faculty extends Staff
class TeachingAssistant extends Staff
class Employee extends UserType
etc
Obviously this all needs to be fleshed out - you may prefer a to use a list
or array to hold the userTypes. The main point being that you have a single
user with one or more extra types. Since the extra types are all of type
"UserType", you can keep adding more and more types without
breaking/modifying the user class. Plus you can modify any of the UserType
subclasses as much as you like. Seems like pretty decent code separation,
plus it's a good basis for future enhancements.
Not sure if it meets your needs.
Cheers,
Rod
<<attachment: winmail.dat>>
