![]() |
Algorithms and Data Structures | ||||
|
ToDo
Lists (doing something with a generic list)
![]() A ToDo item typically has a priority, a description, and an identification number (so I can say, get me item with id=327 for example). We therefore want to hold these ToDo items on a list, and keep them in priority order. We make the assumption that low numbers correspond to high priority. I'm going to use the generic List (as you'd expect). The first thing I must do is define the ToDo.java class. I need to define the instance and class variables, the constructor methods, a toString method (so that I can print it), and accessor functions (to get the protected instance variables). Second, I must define the classes for doing comparisons between ToDo items, with respect to maintaining order. I also need to define the Predicate for testing if a ToDo item has what we are after (in this case a matching identification number). Finally, I need my environment for running it all, Test environment. This creates a List and then allows us to add, delete, insert ToDo items, and much more. Source Code |