Requirement
Write a menu driven program for keeping track of tasks. This requires using an array or using an ArrayList object (either one is okay). The main class will be called TaskManager and the list of tasks will be in this class. Each individual task will be an object of the type Task. This is a separate class (in a separate file) which you create. See Task class below for more details.
If your using the array rather than the ArrayList, you will need to create it to some fixed size. Use 200 and then keep track of how many actual tasks are in the list using a class level in variable (‘listSize’).
Task class
Tasks have fields of name, description, due date and a list of tags. These are to be created in the Task class. Make them private and then create a set of public methods to access and change the values of them. You will need methods to add or delete a tag. You can create a constructor that takes the name, description and due date values (tags are more difficult as you may have anywhere from 0 to 20 of them so do these using the add tag method) OR you can just use a default (no parameters) constructor and use setter methods to add values to the class.
The name, description and tags are strings that can have spaces in them. The due date consists of a month, day and year. These can be stored as three int’s OR you can create another class called TaskDate and store them there. The advantage of having a TaskDate class is that you can also put any comparison and print methods for the date in this class.
Don’t put any methods that require you to work with the entire array inside the Task class. Put these inside the main TaskManager class (along with the array and count). Remember that the Task class only works on the fields of one task, not all tasks.
Description
The following methods should be in your main class:
addTask
Asks the user for the name, description and due date (ask for month, day and year) and any number of tags (up to 20 if your using an array for tags). Then create a Task object and put it into the array (or ArrayList). Check to make sure the task’s name has not already been used as you will be using the name to distinguish between tasks. If there is a duplicate, allow the user to reenter a name. So in the main class you should have a separate findTask method that takes a task name and passes back either the Task object or an index into the array of the Task object that matches the name.
printAllTasks
Prints out all the tasks nicely including the tag lists for each task. It would be more convenient to have a method in the Task class that prints out one task. Then in the main class you only need to use a for loop to call each Task object’s print method.
printTasksByDateRange
Ask for a begin date and end date and print the tasks between the two dates inclusively. It should not print any tasks if the begin date is later than the end date. You’ll need a method for comparing dates. This might be a good candidate for the Task class (or DueDate class) as you would only need to pass in as parameters one date and compare it with the fields in the Task class. Pass back a 1 for the passed in date being later, 0 for it being equal and 1 if the passed in date is earlier.
printTodaysSchedule
A schedule for today consists of printing all past due tasks, then all of today’s task and then all future tasks in that order. In order to do the comparison, the program needs the current data. You can ask the user for this when the program starts up (do this before going into the while loop and keep the current date as a class level variable). Optionally, you can import the java.util.Calendar class to get the current month, day and year but it’s more complicated than just asking the user for the current date.
deleteTask
Ask the user for a name. Find the task with the name. If the name is not there, print an error message and return to the main menu. Else, delete task from the list. For an array, you may have to move the tasks after the deleted task to fill in the ‘hole’ in the array. For ArrayList, you don’t need to do this; just use ‘remove’ method.
modifyTask
Ask the user for a name. Find the task with the name. If the name is not there, print an error message and return to the main menu. Else, print another submenu of possible fields to change: name, description, due date and add or delete tags (see output). Then allow the user to pick a field and change just that attribute in that task. You get point deducted if you force the user to re-enter all information for a task rather than for one field.
quit
Quit should also be a choice in the menu. This should print a goodbye message and quit the program.
Although not necessary, I would suggest putting 3 or 4 tasks into the list when starting up the program. This way you don’t have to re-create a set of tasks every time you run the program. This makes debugging go much faster.
Requirements
You must create and use a Task class; the TaskDate class is optional. You must have the above methods in your program; these go in the TaskManager class. All method listed should be called and work properly.
There should only one array in the main TaskManager class. This should hold Task objects. The Task class also has an array of String objects for hold tags for each task. You will get points off if you have any other arrays in your code.
The fields in your Task class must be private. So you need methods for ‘setting’ and ‘getting’ the fields in your class. These methods should be public. Also, allow the user to add or delete tags in the tag list (no need for a modify for tags) using public methods for this (like addTag and deleteTag which takes a String tag and either adds to the list of tags or finds and deletes from the list of tags).