Homework 4

In this homework, we will create the basis for a shopping list as it should really be -- not as all lame shopping lists are implemented!
We will not worry in this homework about actually making the predictions: we will simply make sure that we store enough information to make predictions possible. In particular, we want to remember which items have been listed together, so that in the future (not in this homework!), we have the data to analyze correlations.

You should store all shopping lists that have been entered in the app (let’s worry later about what to do if the storage grows too large; let us hope that memory capacity in phones will increase faster than our gluttony). For each shopping list, we should store at least the following information:
  • Date created
  • Date of last edit
  • List of items, in the order they were inserted.
An item is not a string.  It is an “entity”, that is, something with its own database row, to which we can associate information.  In practice, you will need an Items table, where you store the item name, and you should create a many-to-many relation between the items, and the shopping lists in which they were entered.  In this way, one can search the item for “mozzarella”, and then see all the shopping lists in which mozzarella was ever ordered, or count how many times in the last month you bought mozzarella, etc etc.
In this Items table, you should store:
  • Item name
  • Item rank (floating point)
  • Item last ordering date.
The item rank and last ordering date will be used to implement suggestions, but again, let’s not worry about it now.  You can just leave the rank to 0, or increment it each time an items is ordered, as  you like.

So, you need to build an app with the following:
  • A “shopping lists” activity, which displays a list of shopping lists (you decide what to show; you can use just the date they were created, or the date and first couple of items), and a button to create a new shopping list.
    • If the user clicks on a shopping list, you switch to the shopping list editor activity for that list.
    • If the user clicks on the button to create a new shopping list, you switch to the shopping list editor for a new list.
  • A “shopping list editor” activity, which shows all the items in the order they were added.  Users should be able to add a new item, that will be placed at the end of the list (so you might want to put the input box at the bottom?  These UI choices are up to you).  You should use ENTER or an on-screen ADD button to add an item, not that funny center-select, to add items!  Clicking the “back” button will bring users back to the “shopping lists” activity.
Data should be stored as detailed above, and the app should save its state.
Comments