![]() |
School of Engineering and Applied
Science
Department of Computer Science CSci 53 -- Introduction to Software Development http://www.seas.gwu.edu/~csci53/spring03 Prof. Michael B. Feldman mfeldman@gwu.edu |
| All
these methods are public static;
none of them write any output to the console.
boolean isValid (int aMonth, int aDay, int aYear) Returns true
if aMonth, aDay,
and aYear form a valid
date whose year is no earlier than 1753, and false
otherwise.
Returns the number of days the month aMonth
has in the year aYear,
or Integer.MIN_VALUE if
either parameter is out of range.
Returns the day of the week (Sunday = 0,
Monday = 1, etc.) for the given month/day/year combination, if that combination
forms a valid date, or Integer.MIN_VALUE
otherwise.
Returns the name of the given month (1
= "January", etc.), if aMonth
is the 1-12 range, and the string "BAD
VALUE" otherwise.
Returns the name of the given day (0 = "Sunday",
etc.) if aDay is in
the 0-6 range, and the string "BAD
VALUE" otherwise.
|
This project is quite different from Projects 1-5. In the others, there was only a single application program, but in this one you are writing a class that provides a set of reusable methods. These methods could be imported into, and used by, any number of different applications.
So how do you test such a thing? Each method must be tested on its own, independently of the others. In effect, each method requires its own little test plan. You can choose to implement each little test plan with a separate test program, or you can write one larger main method that carries out a sequence of little test plans. That choice is up to you, but it must be clear from the test plans, the annotations on your turnin, and your test-program code, how each method is being tested on its own.
boolean validityFlag = false;
while(!validityFlag)
// equivalent to while(validityFlag == false)
{
// prompt for month, day,
and year
if (DateOps.isValid(month,
day, year))
{
validityFlag = true;
}
else
{
System.out.println("Invalid date; please try again");
}
}
For this part you can reuse your test plan from Project 5.
Your grade will be calculated on a 20-point basis, as follows:
MBF 3/25/03