Hi guys,
i am having trouble trying to figure out how to do my assignment.
i need to read in a file of login details (done)
they can be either Instructors or Admins, the problem im having is creating objects of the admin class or instructor class which both extend an Abstract user class.
i was thinking of checking each key in the array, if it contained instructor then create an instructor object.
if it contained admin, create an admin object.
the problem with this i'm having is when i do this the array im storing the objects in muist be of a type, so Instructor and Admin are 2 different types.
could anyone give me some pointers of how to go about accomplishing this.
i dont just want the answer because i'll never learn that way.
Thanks
Code:import java.io.*;
public class RequestApp {
private static String[] users;
private static String[] requests;
private static Admin[] adminArray;
private static Instructor[] instructorArray;
public static void main(String[] args) throws IOException {
// read login text file and create user objects
try {
ReadFile file = new ReadFile();
instructorArray= new Instructor[file.readLines("login.txt")];
adminArray= new Instructor[file.readLines("login.txt")];
users = file.openFile("login.txt");
for (int i = 0; i < users.length; i++) {
if (users[i].contains("instructor")) {
instructorArray[i] = new Instructor(users[i]);
}
}
for (int i = 0; i < users.length; i++) {
if (users[i].contains("admin")) {
adminArray[i] = new Admin(users[i]);
}
}
}
catch (IOException e) {
System.out.println(e.getMessage());
}
}

