Below is the syntax highlighted version of TigerBook.java.

 Reference solution for Spring 2013 COS 126 Programming Exam 2: TigerBook

 Author:       COS 126 Staff
 Netid:        cos126
 Precepts:     lots of them
 Dependencies: Person, ST

 Description:  Models a collection of users (Person objects) each with
               a unique id (String).


public class TigerBook {

    private ST<String, Person> users;  // map each id to a user

    // Constructor
    public TigerBook() {
        users = new ST<String, Person>();

    // Add a person to the list of users.
    // We are allowed to assume this id was not registered yet.
    public void register(String id, Person p) {
        users.put(id, p);

    // Return the person registered with this id.
    // Throw a RuntimeException if no such person exists.
    public Person lookup(String id) {

        // Was this id String registered?
        if (!users.contains(id))
            throw new RuntimeException("User id not found");

        // return the right Person
        return users.get(id);