Comp 170 Week 6

Exam 1 on Wednesday, Feb 18

Notebook revisited
Weblog-graph
Phonebook-HM
NumList
TechSupport


weblog-graph (Chart version of weblog):

    Do analyzeHourlyData() first!
    drawData(): rectangles grow downwards!
    drawData2(): fixed


Phonebook-HM

This is the same StringMap class, except it is based on the standard-library HashMap. Given a key, we can look up a value.


NumList

basic idea: arrays don't literally grow.

ArrayLists keep some growth room, beyond the current size(). When an ArrayList runs out of "extra room", it allocates a new, larger array, copies the old data into this larger array, and updates its own array field to refer to this larger array.

When we need to create extra room, how much should we take? Java ArrayList: 50% more. Drawback to creating just a single extra space.

Can we deal more constructively with out-of-range index values? How about throwing an exception?
    throw outOfRangeException
or something like that.

note how size() works


TechSupport

version 1: all same answer

version 2: add random answers

    Random
   
version 3: add keyword answers
    HashMap
    my version: tech-support-arraylist
       represents sentences in InputReader as ArrayList<String> rather than HashSet<String>
       Note that we can't quite keep these implementation decisions to one class!

version 4:
    two-tier keyword search, then random