Project 8
Due Date: beginning of lecture, Tuesday, November 29, 2005
The goal of this project is to continue with
development
of your own classes. There will be one more project, which will be due
on December 8, the last day of class. Remember that the scores on
Projects 7 and 8 will not be
dropped, as these two projects are too important.
Project:
In this project you will modify
and
test another class from the program library. The results of this
project will
be used in the next (and final) project of the course.
Section 4.5 of the textbook discusses a Java class called Student
which uses another class Address. (The source files are, of
course,
in programs53.) In this part of the project, you are going to
modify the Student class as follows.
- Each student object should also contain the student's unique
student
ID,
in the range 111111 to 999999.
- Each student object should also contain the scores for three
tests,
represented
as float values in the range 0.0-100.0.
- Modify the student constructor so it sets the student ID, name,
and
addresses
from parameter values. The test scores should not be
parameters,
but the constructor should set the three test values to 0.
- Provide an parameterless static
input method readStudent that returns
a student object. It prompts the user for the ID, name, and addresses
of
a student, and calls the constructor to set these values. This method
should
call RobustInput.readInt() to read the student ID.
- Provide a "setter" method called setTestScore that
accepts
two
parameters: the test number (1 through 3) and the score.
- Provide "getter" methods for each of the data fields: getID(), getName(), getHomeAddress(), getSchoolAddress(). Several
examples of how to write these simple "getters" are shown in Chapter 4,
especially the banking example on p. 228-229.
- Also provide a "getter" method called getTestScore(int
whichTest) 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.
- Finally, modify the toString method such that the test
scores
and average are included in the string.
NOTE: Each method must do its own job, and no other. Only readStudent should display any
output on the console.
A "framework" for this class will consist of the existing two methods,
and stubs for the new ones you are adding.
Develop a test plan for this revised student class, and a test program
that carries out your plan. Document your RobustInput and Student
classes with javadoc.
What to submit
"You know what to do -- do it."
MBF 11/17/05