title: Simple java code for Weather Reporting
body: <p>My home work assignment is to figure out:</p>
  
  <ul>
  <li>What this code does</li>
  <li>What potential problems there are</li>
  </ul>
  
  <p>Code</p>
  
  <pre><code>/// Enum
  public enum Event {
      TORNADO, THUNDERSTORM, TSUNAMI, RAIN, SNOW, WIND, COLD, HEAT; 
      public final static String CRITICAL = "Critical";
      public final static String SEVERE = "Severe";
      public final static String MEDIUM = "Medium";
      public final static String LIGHT = "Light";
  
      private String severity;
      private String location;
  
      public void setSeverity(String severity) {
          this.severity = severity; 
      }
  
      public void setLocation(String location) {
          this.location = location; 
      }
  
      public String toString() {
          return super.toString() + ":" + severity + " at " + location; 
      }
  }
  
  ///Interface
  public interface IEventListener {
      void eventReceived(Event event); 
  }
  
  ///Class
  public class EventPublisher implements IEventListener {
      Map&lt;Event, Collection&lt;IEventListener&gt;&gt; listeners = new HashMap&lt;Event, Collection&lt;IEventListener&gt;&gt;(); 
  
      @Override 
      public synchronized void eventReceived(Event event) {
          for (IEventListener listener : listeners.get(event)){ 
              listener.eventReceived(event); 
          }
      }
  
      public synchronized void register(IEventListener listener, Event event){
          Collection&lt;IEventListener&gt; list = listeners.get(event); 
          if (list == null) {
              list = new LinkedList&lt;IEventListener&gt;();
              listeners.put(event, list); 
          }
          list.add(listener);
      }
  
      public synchronized void deregister(IEventListener listener, Event event) {
          listeners.get(event).remove(listener); 
      }
  
      public String toString() {
          String ret = ""; 
          Iterator&lt;Event&gt; i = listeners.keySet().iterator();
          while (i.hasNext()) {
              Iterator&lt;IEventListener&gt; j = listeners.get(i.next()).iterator();
              while (j.hasNext()) {
                  ret = ret + i.next() + "::" + j.next() + "\n"; 
              }
          }
          return ret; 
      }
  }
  </code></pre>
  
  <p>I went through the code and figured out that this code tries to produce the weather report and classify the weather condition based on <code>eventReceived</code> (<code>Event</code> can be registered/deRegistered).</p>
  
  <p>I however cannot see any problems with the code. My teacher insists that there are issues. Can anyone help me?</p>