Project 7
Due Date: beginning of lecture, Thursday, April 10, 2003
The goal of this project is to continue with development
of your own classes.
Project:
In this project you will develop a Java class of your own, and modify and
test one from the program library. The results of this project will
be used in the next (and final) project of the course..
Part 1:
Copy and compile programs53/ShowInputLoop.java, which demonstrates
robust integer input. Examine this program to make sure you understand
it.
Robust input of numerical values is a very common need in software development.
It therefore makes sense to take the ideas used in ShowInputLoop
and build them into a class that provides robust input methods. The file
programs53/RobustInput.java
provides a skeleton for such a class, with the method bodies "stubbed out".
Here is the description of the integer method:
/**
* Reads an integer value from keyboard, robustly.
* The calling program provides minimum and maximum values;
* the method prompts for a value in that range, then displays
* an error message and loops if the input value is
not an
* integer, or is out of range. Once a valid value is entered.
* that value is returned to the calling program.
*/
In this part of the project you will complete and test the two input
methods.
Part 2:
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 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 the 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.
-
Also provide a "getter" 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.
-
Finally, modify the toString method such that the test scores
and average are included in the string.
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 must follow the process given in Systematic
Software Development and the sample project packet distributed
in class.
Your grade will be calculated on a 20-point basis, as follows:
-
6 points -- analysis and design (including relevant algorithms in structured
English), including javadoc pages
-
4 points -- test plans for both parts
-
6 points -- correct execution of both parts according to test plans
-
4 points -- layout and style of program source code
Extra credit:
We'll continue the 2-point bonus for getting an early start. If you e-mail
your "framework" listing file for the Part 2 test program to Prof. Feldman,
and the time stamp on the e-mail is no later than 5 PM, Monday, Apr. 7,
2003, you will be awarded 2 extra project points. The "framework" must
be a listing (.lis) file, with no compilation errors or warnings,
that contains the declared variables, and a set of comments inserted for
the main algorithm steps.
MBF 4/1/03