/** ThreeWayLamp models a lamp that is either off, or in one
 *  of three states: low, medium, or high.  Clients may query
 *  the lamp for its state, or have it cycle through its states.
 */
public class ThreeWayLamp{
  private String lampStatus;


  /** construct a lamp that's off
   *  (saves electricity that way)
   */
  public ThreeWayLamp(){
    lampStatus = "off";
  }
  
  /** return lamp status, one of: off, low, medium, or high
   */
  public String getStatus(){
    return lampStatus;
  }


  /** advance the lamp to the next state in
   *  off-low-medium-high-off cycle.
   */
  public void advance(){
    if (lampStatus.equals("off")){
      lampStatus = "low";
    }
    else if (lampStatus.equals("low")){
      lampStatus = "medium";
    }
    else if (lampStatus.equals("medium")){
      lampStatus = "high";
    }
    else if (lampStatus.equals("high")){
      lampStatus = "off";
    }
  }   

  public void testAdvance(int numAdvances){
    for (int i=0; i<numAdvances; i++){
      this.advance();
    }
  }
}

