public Roster() {
// Instantiate the ArrayList of students
ArrayList<Student> students= new ArrayList<Student>();
}
//
// Operations
//
//
// Helper methods
//
private void createStudents() {
// Create students for the ArrayList
Student aStudent= new Student("Bugs","Bunny",98);
Student bStudent= new Student("Daffy","Duck",77);
Student cStudent= new Student("Elmer", "Fudd",85);
Student dStudent= new Student();
//Add each student to the students ArrayList
students.add(aStudent);
students.add(bStudent);
students.add(cStudent);
students.add(dStudent);
// Use the mutator methods of the Student class to set the fourth Student
// to be "Porky", "Pig", 92
students.get(3).setFirstName("Porky");
students.get(3).setLastName("Pig");
students.get(3).setStudGrade(92);
}
My problem is, I have no idea what he is asking me to do here.
The student class presently looks like this...
public class Student {
//
// Data members
//
private String firstName;
private String lastName;
private int studGrade;
//
// Constructors
//
/**
* Initializes the student data to null or 0.
*/
public Student() {
this.firstName = null;
this.lastName = null;
this.studGrade = 0;
}
/**
* Initializes the first and last name of the student to
* the value of the corresponding parameters.
*
* @param firstName The student's first name.
* @param lastName The student's last name.
* @param studGrade The student's grade.
*/
public Student(String firstName, String lastName, int studGrade) {
this.firstName = firstName;
this.lastName = lastName;
this.studGrade = studGrade;
}
//
// Operations
//
//
// Accessors and mutators
//
/**
* Accessor for student's first name.
*
* @return The first name of the student.
*/
public String getFirstName() {
return this.firstName;
}
/**
* Mutator to set the students first name.
*
* @param firstName The first name to set.
*/
public void setFirstName(String firstName) {
this.firstName = firstName;
}
/**
* Accessor for student's last name.
*
* @return The last name of the student.
*/
public String getLastName() {
return this.lastName;
}
/**
* Mutator to set the students last name.
*
* @param lastName The last name to set.
*/
public void setLastName(String lastName) {
this.lastName = lastName;
}
/**
* Accessor for student's grade.
*
* @return The grade for the student.
*/
public int getStudGrade() {
return this.studGrade;
}
/**
* Mutator to set the student's grade.
*
* @param studGrade The grade to set.
*/
public void setStudGrade(int studGrade) {
this.studGrade = studGrade;
}
}
I know this is problem a simple thing, but again, I am clueless as to what to put in before I can move on with this task.

New Topic/Question
Reply


MultiQuote



|