Let's create a todo list. this first exercise is for when you have just started learning a language and will start out super simple. The whole "application" will be entirely text-based and run on a command line -- no fancy GUIs or databases here.
Print the list
Write a program that prints out youre to-do list. For this first list you can program the list right in and the program doesn't need any conditional logic or anything. You should just be printing out text. If you're not sure where to start, open up an old Hello World program in your language of choice and modify that.
We'll get to these later. Variations are changes or alternate goals to help you practice the content of a particular lesson or step.
Print each list item
You probably printed everything in one big print statement, like this example from Python:
print "Wash the cat. Feed the milk. Buy a fresh carton of car."
That's fine, but later on we're going to want to separate each to-do list item, so let's start moving in that direction. Adjust your program from Part 1 so that each item is in its own print statement. It's fine if your list items print out all on the same line, or each on their own line -- see if you can do both if you want to learn a little more about formatting text.
Create a printTask
function that takes each task as an argument and prints it out.
- Instead of passing each task one at a time, you can refactor your function to take an array of tasks and print all of them. This requires knowledge of looping logic.
Print the status of each task
Let's change that function a little bit. Refactor it to take two argments -- the task to print (as a string) and a boolean (true/false) defining whether the task is done. Adjust the output of your function to print the status of each task next to the task.
Tasks as objects
The string defining a task and the boolean defining its status are logically related, so let's embody that relationship in our code. Create an object type (or a class or a struct, depending on your language) that represents a task. Define the two fields a task has (eg: name and doneStatus) and use this in place of the strings and booleans you were passing to your function. You will need to refactor the function to take a Task object and use its fields, and change your code to create Task objects for each task.
You could add other fields to Tasks, such as a more detailed description, and due date or completion date. Try adding one or more of these and changing your printTask function to show the relevant information as well. Be careful not to print the completion date of incomplete tasks. Try printing overdue tasks in all capital letters.
Once week 2 is fleshed out the next steps are: