CSCI 180/181 Spring 2008, Project 1
A calendar date consists of a day, month and a year.
Your task in this project (named project1) is to implement a class called
CalendarDate that allows the
creation, query and manipulation of a date. The
class should provide the following functionality:
D-level functionality (correctness)
- A constructor that is given the day, month and year, and
constructs the date.
- A display() method that displays
the date to the terminal.
C-level functionality (correctness)
D-level plus these additional methods:
- A setUSDisplay() method that sets
the display mode for the date to be in US mode --
month/day/year.
- A setEuropeanDisplay() method
that sets the display mode for
the date to be European -- day/month/year.
setUSDisplay() and setEuropeanDisplay()
are mutually exclusive. The date will be displayed one way
or the other, not both!
- A setDisplayMonthName() method
that sets the display mode
to write the name of the month rather than the
number.
- A setDisplayMonthNumber()
method that sets the display mode
to write the number of the month rather than the
name. setDisplayMonthName() and
setDisplayMonthNumber() are mutually exclcusive.
B-level functionality (correctness)
C-level plus these additional features:
- validity testing: disallow construction of a date if it is
not valid. A date is invalid if the day is incorrect
(too big or too small), the month is incorrect
(too big or too small), or the year is incorrect (too small).
Note that the February 29 is valid for leap years. A leap
year
- is larger than 1582;
- is divisible by 4 but
- is not divisible by 100 unless it is also divisible
by 400.
If the date is invalid, set the date to an default date (any
correct date is okay).
- A method boolean isEarlierThan(CalendarDate
comparisonDate) which takes a single
parameter, also a date, and returns a boolean which is true
if this date is earlier than the comparison date passed as a
parameter.
A-level functionality
Along with the B-level add at least one additional feature to your
CalendarDate class. The features should be non-trivial
and should indicate some effort. If you have an idea and are not
sure, clear it with me first. Some acceptable additions include:
- Methods addDays, addMonths,
addYears , each of which takes
an integer and adds that many days, months, or years onto the
date. (The resulting date should be a legal, valid date, of
course.)
- Incorporation of days of the week into the display of the
date. (It should display the correct day of the week, but
the constructor should not change.)
- Display of the calendar in another system, e.g. Chinese,
Julian, Roman, Mayan.
Notes on Style
See the style guide posted on our web site.
Approximately 30
percent of your project grade will be based on coding style,
including documentation. Generally I will divide this into an
assessment of
- documentation -- the comments and specifications for your
code.
- naming -- quality names that make your code more
self-documenting.
- code structure -- the structuring of the code itself: line
and method lengths, indentation, whitespace, clarity of code,
efficiency of code. (Efficiency is not a big concern early on.)
Deliverables -- what should you hand in?
- Each time you work, please complete an entry in this electronic journal. The log is intended
to help you and I analyze your behavior over time -- noticing
where you spend time or have problems, and to help me give you
advice on your process as well. You will not lose
points for what may seem to be questionable practices, but you
will lose points for not providing the log.
- Your code.
The handin name for this project is project1. It
will be due at 23:59 Friday, February 8. When you hand it in, please handin the entire directory for project1
handin 180 project1 project1/*
Check the syllabus for a discussion of academic honesty. This project must be your own work.