Preface: This is an assignment, so that's why I have usernames and passwords as plain text in a CSV file.
Here's what I've been given:
username, password, staff type as my data file.
The latter being either E for Employee, M for Manager or C for Contractor. Each of these are represented by their own classes, with their own methods.
I have implemented a function that authenticates the username/password that the user enters. I just now am stuck on how to create an object based off of that last staff type value.
My naive solution at first was to do something like:
if (staffType.equals("E")) {
Employee user = new Employee();
else if (staffType.equals("C")) {
Contractor user = new Contractor();
else if (staffType.equals("M")) {
Manager user = new Manager();
}
However I then tried to wrap this in a method, and I'm stuck on what to put as the return type. I've had a year break from Java and OO in general so unfortunately all the concepts of polymorphism, inheritance, generic methods and so on are fuzzy to me.
Obviously in light of this being an assignment I don't want a full implementation, just a hint in the right direction.
Thanks everyone