title: Best data type for a simple reservation system in java
body: <p>I'm trying to create a trivially simple reservation system to practice TDD. I initially tried an ArrayList with a set number of spaces representing times, then a Map and both seemed close, but neither ultimately worked.
  Immutibilty is key and I've used a constructor to set the capacity and am trying to have the setter depend on the empty-string-ness or nullabilty (tried both) of the String value:</p>
  
  <pre><code>public class BookingSystem {
  
      private BookingSystem bookingSystem;
      private Map&lt;Integer, String&gt; classList;
  
      public HashMap&lt;Integer, String&gt; setClassList() {
          for (int i=0;i&lt;24; i++) {
              classList.put(0, "");
          }
          return classList;
      }
  
      public void bookClassroom(int time, String room) throws BookedException {
          if (classList.get(time).equals("")) {
              classList.put(time, room);
          } else {
                  throw new BookedException();
          }
      }
  </code></pre>
  
  <p>This seems like a hack, but also seems logical to me. Is a HashMap overkill and would a simple list or array suffice? I've tried them all but haven't quite hit it and now I feel like now I'm overly mired in the many, many Java data structures.</p>
  
  <p>Next step would be to make Classrooms its own class and an enum, but first I have to get the basics down!</p>
  
  <ul>
  <li>edit: Stuck behind a firewall that's not allowing me to comment on others' posts. Each index of the array/list/map should suffice as "an hour". the list will be 8 or 24 indices long (it doesn't matter, thus performance is not an issue). </li>
  </ul>