Seventh lab: Calendar: Part 3
Learning Objective(s)
- Learn to work with text files
- Learn to use exceptions
- Improve ability to use methods
Overview of the program
This lab should track the number of hours scheduled to be done in a day.
Details
- The program should be called CalendarKeeper
- Activities include:
- Adding a task to a day (for a given date, the number of hours and the name of a task).
- Display all tasks associated with a given day
- Display the number of hours scheduled to that day
- Display the number of hours scheduled for a month
- File information
- Information about a given day should be stored in a file specified by the date (i.e. 2022_03_15) for March 15, 2022
- Each line starts with an integer specifying the numbers of hours and then a string specifying the task
- The program should allow tasks to be appended to a given file.
- Exception information
- All possible exceptions should be handled by your program.
- If the user specifies an invalid date, through an exception and catch it in the method that called it
- Method information
- Use one method to get the date from the user
- Use a separate method for each activity
- Input:
- When getting a date, ask for the year first, then the month, then the day. (All should be numbers)
- You must support the following for user input. You may supplement with other options.
- 0 (the number not letter) will be used to indicated no more work
- 1 will be used to indicate that a task is to be added
- 2 will be used to indicate that the user wishes to display the information about a day
- 3 will be used to indicate that the user wishes to see the number of hours assigned to a day
- 4 will be used to indicate that the user wishes to see the number of hours assigned to a month
- a line of input associated with a new task will look like the following. It indicates that the user plans to spend 3.5 hours on the task of writing code.
3.5 write code
Partial sample dialogue
Which do you want to do?
1) add a task to a day
2) display everything assigned to a day
3) display the number of hours assigned to a day
4) display the number of hours assigned to a month
0) quit
1
What year, month, and day associated with your task?
2022 5 15
What is the task?
code
How many hours do you think it will take?
3
Which do you want to do?
1) add a task to a day
2) display everything assigned to a day
3) display the number of hours assigned to a day
4) display the number of hours assigned to a month
0) quit
1
What year, month, and day associated with your task?
2022 5 15
What is the task?
study
How many hours do you think it will take?
2.5
Which do you want to do?
1) add a task to a day
2) display everything assigned to a day
3) display the number of hours assigned to a day
4) display the number of hours assigned to a month
0) quit
1
What year, month, and day associated with your task?
2022 4 21
What is the task?
relax
How many hours do you think it will take?
1.5
Which do you want to do?
1) add a task to a day
2) display everything assigned to a day
3) display the number of hours assigned to a day
4) display the number of hours assigned to a month
0) quit
2
What year, month, and day associated with your task?
2022 5 15
The tasks for that day are:
3.0 code
2.5 study
Which do you want to do?
1) add a task to a day
2) display everything assigned to a day
3) display the number of hours assigned to a day
4) display the number of hours assigned to a month
0) quit
3
What year, month, and day associated with your task?
2022 5 15
The total number of hours for that day are 5.5.
Which do you want to do?
1) add a task to a day
2) display everything assigned to a day
3) display the number of hours assigned to a day
4) display the number of hours assigned to a month
0) quit
0
Submission
- Create an empty zip folder.
- Place your program (.java file) in it
- Place your software development report in it.
- Submit the zip folder on canvas
Optional improvements
none this time