title: Populating a Boolean Array in Java
body: <p>As a fairly green Java coder I've set myself the hefty challenge of trying to write a simple text adventure. Unsurprisingly, I've encountered difficulties already! </p>
  
  <p>I'm trying to give my Location class a property to store which exits it contains. I've used a boolean array for this, to essentially hold true/false values representing each exit. I'm not entirely convinced that </p>
  
  <p><strong>a)</strong> this is the most efficient way to do this and </p>
  
  <p><strong>b)</strong> that I'm using the right code to populate the array.</p>
  
  <p>I would appreciate any and all feedback, even if it is for a complete code over-haul!</p>
  
  <p>At present, when instantiating a Location I generate a String which I send through to the setExits method:</p>
  
  <pre><code>    String e = "N S U";
      secretRoom.setExits(e);
  </code></pre>
  
  <p>In the Location class, setExits looks like this:</p>
  
  <pre><code>public void setExits(String e) {
      if (e.contains("N"))
          bexits[0] = true;
      else if (e.contains("W"))
          bexits[1] = true;
      else if (e.contains("S"))
          bexits[2] = true;
      else if (e.contains("E"))
          bexits[3] = true;
      else if (e.contains("U"))
          bexits[4] = true;
      else if (e.contains("D"))
          bexits[5] = true;
  }
  </code></pre>
  
  <p>I'll be honest, I think this looks particularly clunky, but I couldn't think of another way to do it. I'm also not entirely sure now how to write the getExits method...</p>
  
  <p>Any help would be welcome!</p>