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


/**
  A mattress and its orientations;&nbsp;
  the mattress's state (its orientation)
  is implemented with three booleans.

  <table frame='box' rules='all'>
  <tbody>
    <tr>
      <th>  </th>
      <th rowspan='7'></th>
      <th colspan='3'> To, after a ... </th>
    </tr>

    <tr>
      <th> From </th>
      <th> pitch </th>
      <th> roll </th>
      <th> yaw </th>
    </tr>

    <tr>
      <td colspan='5'></td>
    </tr>


    <tr>
      <td> FLB </td>
      <td> HLT </td>
      <td> FRT </td>
      <td> HRB </td>
    </tr>

    <tr>
      <td> FRT </td>
      <td> HRB </td>
      <td> FLB </td>
      <td> HLT </td>
    </tr>

    <tr>
      <td> HLT </td>
      <td> FLB </td>
      <td> HRB </td>
      <td> FRT </td>
    </tr>

    <tr>
      <td> HRB </td>
      <td> FRT </td>
      <td> HLT </td>
      <td> FLB </td>
    </tr>

  </tbody>
  </table>

  <p>
  The FLB, FRT, etc. codes in the table above
  are interpreted as follows:

  <table frame='box' rules='all'>
  <tbody>
    <tr>
      <th> Code </th>
      <th> Meaning </th>
    </tr>

    <tr><th>B</th> <td> Bottom is green </td></tr>
    <tr><th>F</th> <td> Foot   is red   </td></tr>
    <tr><th>H</th> <td> Head   is red   </td></tr>
    <tr><th>L</th> <td> Left   is blue  </td></tr>
    <tr><th>R</th> <td> Right  is blue  </td></tr>
    <tr><th>T</th> <td> Top    is green </td></tr>

  </tbody>
  </table>

*/
public class Mattress1 implements PRYable {

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

  /**
    True if this mattress is oriented blue-end at left.
  */
  private boolean left;

  /**
    True if this mattress is oriented green-surface at top.
  */
  private boolean top;

  /**
    Constructs a mattress
    with red-end at top,
    blue-end at left,
    and green-surface at top.
  */
  public Mattress1() {
    head = true;
    left = true;
    top  = true;
  }

  public String toString() {
    return
        (head ? "H" : "F") +
        (left ? "L" : "R") +
        (top  ? "T" : "B");
  }

  public boolean headRed() {
    return       head;
  }

  public boolean leftBlue() {
    return       left;
  }

  public boolean topGreen() {
    return       top;
  }

  public PRYable pitch() {
    head = !head;
    top  = !top ;
    return this;
  }

  public PRYable roll() {
    left = !left;
    top  = !top ;
    return this;
  }

  public PRYable yaw() {
    head = !head;
    left = !left;
    return this;
  }

}
