I have a Student.java which has get and set methods(because the variables are private). And I will have a StudentTest.java which should read the first name, last name ,student id and store them in the array.
I guess I need to create an array in Main file and then read it from user in the test file. And at the end it should print out whatever is in the array
Can someone help me with how to do this?
Student.java
public class Student {
private String firstName;
private String lastName;
private String studentNumber;
public String studentList[][][];
Student(String fName,String lName,String sNumber)
{
firstName=fName;
lastName=lName;
studentNumber=sNumber;
}
public Student()
{
}
public void setFirstName(String fName)
{
firstName=fName;
}
public String getFirstName()
{
return firstName;
}//end the method setfirstName
public void setLastName(String lName)
{
lastName=lName; // Store the lastName
} // end the method setlastName
public String getLastName()
{
return lastName;
}
public void setStudentNumber(String sNumber)
{
studentNumber=sNumber;
} // end the method setstudentNumber
public String getStudentNumber()
{
return studentNumber;
}
public String toString() // use of toString method to print the objects
{
return String.format("%-8s %-9s %-8s\n",firstName,lastName,studentNumber );
}//end method toString
}//end class Student

New Topic/Question
Reply




MultiQuote








|