Here are the requirements: Modify the Student class from chapter 6 as follows. Each student object should also contain the scores for three tests. Provide a constructor that sets all instance values based on parameter values. Provide a zero-parameter constructor that sets each test score to zero. Provide a method called setTestScore that accepts two parameters: the test number (1 through 3) and the score. Also provide a method called getTestScore that accepts the test number and returns the appropriate score. Provide a method called average that computes and returns the average test score for this student. Modify the toString method such that the test scores and average are included in the description of the student. The driver class is called TestStudent. Modify the driver class main method to exercise the new Student methods.
My first question would be: What's a zero parameter constructor? Also can anyone give any hints or a simplified version of what exactly I'm supposed to do?
Here is the Student class:
package chap06;
/**
* Represents a college student.
* @author Lewis
* @author Loftus
* @version 1
*/
public class Student {
/** First name of this student. */
private String firstName;
/** Last name of this student. */
private String lastName;
/** Home address of this student. */
private Address homeAddress;
/** School address of this student. Can be shared by other students */
private Address schoolAddress;
/**
* Constructor: Sets up this student with the specified values.
* @param first The first name of the student
* @param last The last name of the student
* @param home The home address of the student
* @param school The school address of the student
*/
public Student(String first, String last, Address home, Address school) {
firstName = first;
lastName = last;
homeAddress = home;
schoolAddress = school;
}
/**
* Returns a string description of this Student object.
* @return formatted name and addresses of student
*/
public String toString() {
String result;
result = firstName + " " + lastName + "\n";
result += "Home Address:\n" + homeAddress + "\n";
result += "School Address:\n" + schoolAddress;
return result;
}
}
I'm also getting errors for private Address homeAddress; and private Address schoolAddress; saying Address cannot be resolved to a type.
This was the code provided so I'm not sure why there's errors.

New Topic/Question
Reply




MultiQuote







|