Last active
December 12, 2015 08:08
-
-
Save JustSilverman/4741386 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Components | |
1. Database - Text file (maintains each list item) | |
2. User device - Takes input and displays output to user | |
3. Middleman - Translates between database and user device | |
- (i.e. takes input from user device and tells database to save it) | |
- (i.e. asks database for current list or specific list items) | |
Potential Classes | |
ListItem - (id, task (text), status) | |
List - Array ListItem objects | |
UserInterface - displaying output to user | |
Middleman - Translates prompt into action (get, add, delete, complete, list) | |
Database - Maintains each list item (ListItems, get, add, delete, complete, list) | |
__________________ | |
ListItem | |
-Attributes - id, item (string), status | |
-Methods - | |
List | |
-Attributes - list_items (array of ListItems) | |
-Methods - get_item, delete_item, update_status | |
Middleman | |
-Attributes - Database, UserInterface | |
-Methods - (get, add, delete, complete, list) | |
DRIVER CODE | |
action => set to some action from parser | |
item_id => only for delete and complete | |
task => actual string of the task | |
middle_man = MiddleMan.new({:action => action, :item_id => item_id, :task => task}) | |
if action is add | |
middle_man.add(task) ---> @database.add_item(task) | |
if action is list | |
middle_man.get_list ---> @database.get_list | |
middle_man.send_list ---> @user_interface.display_list(list) | |
if action is delete | |
middle_man.delete(id) ---> @database.delete(id) | |
if action is complete | |
middle_man.complete(id) ---> @database.complete(id) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment