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

Project 7
Due Date: beginning of lecture, Thursday, Nov. 17, 2005

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 a pre-existing class, test these, then use the enhanced DateOps class to  help you rewrite your calendar program from Project 6.

Part 1:

Add the following methods to the DateOps 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 aMonthaDay, 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-6. 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.

What's a "framework" for a reusable class? It consists of a stub for each one of the methods. A stub is a method whose body is either empty (if it's a void method) or contains a single return statement that returns one constant value (if it's a value-returning mathod). For example, here's a stub:
 
int daysInMonth (int aMonth, int aYear)
{
  return 28;
}


As with the other frameworks, a framework for a reusable class must be compilable!

Part 2:

Now modify your program from Project 6 so as to use the methods from this class to the greatest extent possible. Use your RobustInput class to validate the user's starting and ending values, then use DateOps to validate the resulting dates.

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, Friday, Nov. 11, you will be awarded 2 extra project points. The "framework" must be a listing (.txt) file, with no compilation errors or warnings, that contains the declared variables, and a set of comments inserted for the main algorithm steps.

MBF 11/7/05