Object Oriented Software Design (NTU, Class 01/02, Spring 2009) instructor: Hsuan-Tien Lin
Homework #1
RELEASE DATE: 03/04/2010 DUE DATE: 03/18/2010, 12:00
As directed below, you need to upload your submission file to the designated place on the course website.
Any form of cheating, lying or plagiarism will not be tolerated. Students can get zero scores and/or fail the class and/or be kicked out of school and/or receive other punishments for those kinds of misconducts.
Discussions on course materials and homework solutions are encouraged. But you should write the final solutions alone and understand them fully. Books, notes, and Internet resources can be consulted, but not copied from.
Since everyone needs to write the final solutions alone, there is absolutely no need to lend your homework solutions and/or source codes to your classmates at any time. In order to maximize the level of fairness in this class, lending and borrowing homework solutions are both regarded as dishonest behaviors and will be punished according to the honesty policy.
Both English and Traditional Chinese are allowed for writing any part of your homework (if the compiler recognizes Traditional Chinese, of course). We do not accept any other languages.
1 Description
The POO BBS finds a website called MilitaryCalendar to be really popular, and thus wants to have this functionality in the system. The MilitaryCalendar website
http://www.work.caltech.edu/~htlin/program/doc/MilitaryCal.html
computes the retirement date of soldiers in Taiwan. The date is computed according to the following rules:
(1) From the entrance date, one year and ten months are added. That is, “March 04, 2010” becomes
“January 04, 2012”; “August 31, 2010” becomes “June 30, 2012” (note that there is no 31st in June).
(2) From the result, any deductions (e.g. from taking the Military Training class) are subtracted, day by day. For instance, if there are 6 days of deductions, “January 04, 2012” becomes “December 29, 2011.”
(3) From the result, 10 months are subtracted. That is, “December 29, 2011” becomes “February 28, 2011” (note that there is no 29th in that February); “December 20, 2011” becomes “February 20, 2011.”
We will simplify your task in this first homework. Your program should first show the information of you, the sacred author. Then, prompt the user to enter her/his name, entrance year, entrance month, entrance day and total number of deduction days as five separate questions. Be careful about wrongly- typed values if you can. Finally, compute her/his retirement date. The screen output of your program will be something like
Mini Military Calendar, written by b86506054 Hsuan-Tien Lin Please enter your name: CharlieL
Please enter your entrance year: 2010 Please enter your entrance month: 2 Please enter your entrance day: 31
There is no day 31 in month 2 of year 2010. Please try again.
Please enter your entrance day: 28
Please enter the total number of deduction days (0 meaning no deduction): -3 Really? You are doing 3 days more? That does not seem right. Please try again.
Please enter the total number of deduction days (0 meaning no deduction): 16 Dear CharlieL, your entrance date is 2010/02/28;
total number of deduction days is 16;
retirement date is 2011/02/12.
1 of 2
Object Oriented Software Design (NTU, Class 01/02, Spring 2009) instructor: Hsuan-Tien Lin
Write a Java program that does the task above. The TAs may use some systematic test data to verify the correctness of your program so please follow the order of questions strictly. An empty shell of your program should look like
public class POOMilCalendar {
public static void main(String[] args) { //start your own code here
} }
You don’t need to define more methods for the program if you don’t want (or don’t know how) to.
2 Requirements
• Finish the task described above. Note that you should replace the by b86506054 Hsuan-Tien Lin string with your own school ID and name.
• Write some comments for your code, and generate the document with javadoc. In your comments (of main), explain the purpose of your program.
• Write a short report with at most one A4 pages that contains the following items:
(1) your name and school ID
(2) how you tested the correctness of your program
(3) any part that you implemented that is worth getting “bonus” points (we’ll allocate at most 5 bonus points for this homework)
You should submit your report in PDF format. See http://jsc.cc.ntu.edu.tw/ntucc/pcroom/
manual/Word2Pdf.htm for some possible instructions for converting from Word to PDF.
Other than the basic task above, you can use your creativity to design a better program. For instance, you do not really need to use English in your messages/comments.
3 Submission File
Please upload a single ZIP encrypted file to CEIBA. The zip file should be like b86506054.zip, where the file name should be changed to your own school ID. The ZIP file should contain the following items:
• POOMilCalendar.java, which is your source code
• POOMilCalendar.class, which is the compiled from POOMilCalendar.java
• doc/*, which is the file generated from javadoc -d doc/ POOMilCalendar.java
• README, which contains directions on how to compile your file
• Your report file in PDF format
2 of 2