hi i am a totally new guy on JAVA OO concepts ,and this is my first time programming,i am currently stuck on how to create a registration class and a class which will store all the registration info, this is what i have done, 4 classes, a Account class, a Staff class extend Account,a Student class extend Account, and a dataStorage class to store the informations and to extract them when needed.
public class Account {
private String name;
private String department;
private String username;
private String password;
public Account()
{
}
public Account(String nm,String dep,String user,String pass)
{
name = nm;
department = dep;
username = user;
password = pass;
}
public void setName(String nm)
{
name = nm;
}
public String getName()
{
..... other accessors
}
/**/
public class Student extends Account {
private String studentNRIC;
private String studentID;
public Student(String n, String nr, String id, String dep, String user, String pass)
{
super(n, dep, user, pass);
studentNRIC = nr;
studentID = id;
}
public void setStudentNRIC(String nr)
{
studentNRIC = nr;
}
public String getStudentNRIC()
{
return studentNRIC;
}
....accessors
}
/**/
public class Staff extends Account {
private String staffID;
public Staff(String n, String id, String dep, String user, String pass)
{
super(n, dep, user, pass);
staffID = id;
}
public void setStaffID(String id)
{
staffID = id;
}
public String getStaffID()
{
return staffID;
}
}
/**/ import java.util.*;
public class DataStorage
{
ArrayList<Account> staff = new ArrayList<Account>();
ArrayList<Account> student = new ArrayList<Account>();
public DataStorage(Staff aAcc)
{
staff.add(aAcc);
}
public DataStorage(Student aAcc)
{
student.add(aAcc);
}
public String msg()
{
Staff sf = staff.get(0);
return staff;
}
}