//  (c) 2010 Thomas A. Alspaugh.  All rights reserved.
package oo;


/**
  A mattress and its orientations;&nbsp;
  state implemented as a single object of an inner class.
*/
public class Mattress3 implements PRYable {

  /**
    True if this mattress is oriented red-end at head.
  */
  private Orientation orientation;

  /**
    Constructs a mattress
    with red-end at top,
    blue-end at left,
    and green-surface at top.
  */
  public Mattress3() {
    orientation = Orientation.HLT;
  }

  public String toString() {
    return orientation.toString();
  }

  public boolean       headRed() {
    return orientation.headRed();
  }

  public boolean       leftBlue() {
    return orientation.leftBlue();
  }

  public boolean       topGreen() {
    return orientation.topGreen();
  }

  /**
    The mattress's orientation.
  */
  public Orientation orientation() {
    return           orientation;
  }

  public PRYable       pitch() {
    orientation = Flip.PITCH.flip(orientation);
    return this;
  }

  public PRYable       roll() {
    orientation = Flip.ROLL.flip(orientation);
    return this;
  }

  public PRYable       yaw() {
    orientation = Flip.YAW.flip(orientation);
    return this;
  }

}
