School of Engineering and Applied Science
Department of Computer Science
CSci 53 -- Introduction to Software Development
http://www.seas.gwu.edu/~csci53/fall02
Prof. Michael B. Feldman
mfeldman@seas.gwu.edu

Project 6
Due Date: beginning of lecture, Thursday, Nov. 7, 2002

The goal of this project is to develop some methods in a class, and to use them in an application program.

Project:

We have reached the stage in the course where it's time to start writing our own methods and classes. The objective in this project is to add some methods to the DateOps class we used in Project 4, test these, then use the enhanced DateOps class to  help you rewrite your calendar program from Project 5.

Part 1:

You already have the original DateOps class in your directory. Here are the method descriptions for the enhanced class.

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.

int daysInMonth (int aMonth, int aYear)
Returns the number of days the month aMonth has in the year aYear, or Integer.MIN_VALUE if either parameter is out of range.

int dayOfWeek(int aMonth, int aDay, int aYear)
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.

String monthName (int aMonth)
Returns the name of the given month (1 = "January", etc.), if aMonth is the 1-12 range, and the string "BAD VALUE" otherwise.

String dayName (int aDayOfTheWeek)
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.

Part 2:

Now modify your program from Project 5 so as to use the methods from this class to the greatest extent possible. Also make two changes to the program:
  1. validate the input dates
  2. add the day name to each date written to the output file, e.g.,
    Wednesday, October 23, 2002
In validating the input date, give the user a chance to keep trying if (s)he enters an invalid date. For each of the two input dates, your program will have a loop that uses a boolean flag variable:

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.

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:

Extra credit:

We'll continue the 2-point bonus for getting an early start. If you e-mail your "framework" listing file for Part 1 to Prof. Feldman, and the time stamp on the e-mail is no later than 5 PM, Monday, Nov. 4, 2002, 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 10/23/02