CS 161 Homework 7 - To Do List

Due Thu Apr 04 at 11:59pm

Overview

ArrayLists are an ideal class for letting us organize and track information. In this assignment, you will use ArrayLists in writing a program to maintain a "To Do List"--a list of tasks that need to be done. This list will be managed through the command-line. Your list will support a number of functions including: adding new tasks, printing out all of the tasks, marking tasks as complete, removing tasks, and finding tasks that are due in the near future.

Below are a frew representative samples of what the output of your program should look like:

Select an option:
1. List all tasks in the to do list
2. Add a task to the to do list
3. Mark a task as completed
4. Remove a task from the to do list
5. Remove all completed tasks
6. List all tasks due due soon
7. Get the next task to do
8. Exit system
> 1

*** YOUR TO DO LIST ***
<<COMPLETED>>  Write "to-do list" assignment
<<INCOMPLETE>>  Pay taxes
   due Mon Apr 15 13:00 2013
<<INCOMPLETE>>  Feed the cat
   due Mon Apr 01 18:30 2013
<<COMPLETED>>  Save the world from evil killer robots
<<INCOMPLETE>>  Finish homework
   due Thu Apr 04 23:59 2013

...
> 6

*** TASKS DUE WITHIN 3 DAY(S) ***
<<INCOMPLETE>>  Feed the cat
   due Mon Apr 01 18:30 2013
<<INCOMPLETE>>  Finish homework
   due Thu Apr 04 23:59 2013

...
> 7

*** NEXT TASK TO DO ***
<<INCOMPLETE>>  Feed the cat
   due Mon Apr 01 18:30 2013

Note that I am providing the menus and interaction for you--all you need to do is actually add the to do list's functionality!

This assignment should be completed individually. You are welcome to ask for help (either from me or from your classmates), but remember the Gilligan's Island rule!

Objectives

Necessary Files

You will need to download and extract the BlueJ project from the Homework7.zip file. This project includes two provided classes: This project will supply you with the following classes:

Finally, the project contains a README.txt file that you will need to fill out. Remember that you can open this file in BlueJ by double-clicking on the white paper icon!

Details

First, read through all of the assignment carefully. As you do so, think about what kinds of methods you might need, what kinds of variables you may want, and what kinds of functionality you will need.

Your program will need two classes: a Task class to represent a Task, and a ToDoList task that models your to do list. Both of these classes are required by the ToDoListManager. Note that most of your code will go inside the ToDoList class.

Again, you will probably want a ToDoListTester class to help debug your program.

Timeline

This assignment is around the same size as Hangman, but you have a little less guidance so it may take longer. Get started early so that you have time to recover from any false starts (and there may be some false starts!)

Submitting

Check and double-check that your program works, that your code is commented, and that your name is in the class comment at the top of your program!

Be sure to complete the provided README.txt file with details about your program.

Upload the entire BlueJ project to the Hwk7 folder on the submission folder on hedwig. Make sure you upload your work to the correct folder!. This assignment is due at midnight on Thu Apr 04.

Extensions

There are lots of ways to extend this assignment and add more details to your To Do List (and the manager)

Grading

This assignment will be graded on approximately the following criteria:

Documentation

Below is an example Javadoc from a working ToDoList.



Class ToDoList

java.lang.Object
  ToDoList

public class ToDoList extends java.lang.Object

A class that manages a list of tasks to do


Constructor Summary
ToDoList()
          Makes a new ToDoList object
ToDoList(int todayYear, int todayMonth, int todayDayOfMonth)
          Makes a new ToDoList object with the given year, month, and dayOfMonth representing "today" This constructor is optional.
 
Method Summary
 void addTask(String description, DateTime dueDate)
          Adds a new Task to the to do list.
 Task getNextTask()
          Returns the "next" task to do.
 void listAllTasks()
          Prints out all of the tasks in the to do list
 void listNextTasks(int days)
          Prints out all of the tasks in the to do list that are due within the specified number of days.
 void listTasks(ArrayList<Task> tasks)
          A helper method that prints out the items in the given ArrayList of tasks.
 Task lookup(String description)
          A helper method that finds the Task with the given description in the to do list
 boolean markTaskCompleted(String descr)
          Marks the task with the given description as completed
 boolean remove(String description)
          Removes the task with the given description from the to do list
 void removeCompleted()
          Removes all completed tasks from the to do list
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ToDoList

public ToDoList()
Makes a new ToDoList object


ToDoList

public ToDoList(int todayYear,
                int todayMonth,
                int todayDayOfMonth)
Makes a new ToDoList object with the given year, month, and dayOfMonth representing "today" This constructor is optional.

Parameters:
todayYear - The year of "today"
todayMonth - The month of "today"
todayDayOfMonth - The day of the month of "today"
Method Detail

addTask

public void addTask(String description,
                    DateTime dueDate)
Adds a new Task to the to do list.

Parameters:
description - The description of the task to add
date - The dueDate of the task to add

getNextTask

public Task getNextTask()
Returns the "next" task to do. This is the incomplete task with the closest due date (that has not passed yet).

Returns:
The next task to do, or null if there is no task to do!

listAllTasks

public void listAllTasks()
Prints out all of the tasks in the to do list


listNextTasks

public void listNextTasks(int days)
Prints out all of the tasks in the to do list that are due within the specified number of days. Note that this can include tasks that are completed or past due

Parameters:
days - How many days worth of tasks to list

listTasks

public void listTasks(ArrayList<Task> tasks)
A helper method that prints out the items in the given ArrayList of tasks. Note that this can be used to print either the tasks in the to do list, or another ArrayList of tasks

Parameters:
tasks - The ArrayList of tasks to print out

lookup

public Task lookup(String description)
A helper method that finds the Task with the given description in the to do list

Parameters:
description - The description of the task to find
Returns:
The task with the given description, or null if the task is not found

markTaskCompleted

public boolean markTaskCompleted(String descr)
Marks the task with the given description as completed

Parameters:
descr - The description of the task to mark as completed
Returns:
whether or not the task was marked completed (can be false if the task was not in the list)

remove

public boolean remove(String description)
Removes the task with the given description from the to do list

Parameters:
description - The description of the task to remove
Returns:
whether or not the task was removed (can be false if the task was not in the list)

removeCompleted

public void removeCompleted()
Removes all completed tasks from the to do list