/******************************* MAIN HEADER **********************************
 Title:           Illustration of some basic java syntax
 Files:           Chair.java

 CS 302 Lecture Material
 *****************************************************************************/

//import packages here--we don't require any for this class
//import <package name>.<class name>
//for instance: 

public class Chair {

  /*this is a constructor, i.e. a method invoked (executed) upon
    creation of any object of type Chair.
    In this example, every Chair object
    (e.g., chair1, chair2, etc.) will have a separate copy of tagID 
    in it.  However, numMade will be shared among all objects.
  */

  Chair(int inputTagID) {
    tagID = inputTagID;
    numMade++;
    myColor = NOT_PAINTED;
    myColorString = "Not Painted";
  }
  

  //fields

  //here is one instance where it's OK to make these "public" even though they are fields (not methods)
  //Q: why is it OK? (answer should be easy)
  public static final int NOT_PAINTED = 0,
  			   BLUE = 1, 
  			   RED = 2, 
			   GREEN = 3; //class constants
 
  //instance constant (differentiates objects, non-modifiable once assigned)
  private final int tagID; 
  
  /*class variable--add 1 each time a new chair is made (shared, modifiable)
  note:  we want to make sure that numMade == 1 after the first chair is made,
  so we set it to zero when no chairs have been made yet. */
  private static int numMade = 0;

  //instance variable (differentiates objects, modifiable--can change via SetColor()
  private int myColor;  		
  private String myColorString;
 
  public void PrintColor() {
	System.out.println("Chair # " + tagID + " is: " + myColorString + ".");
  }

  /* This method sets the color according to an integer passed in inside of Main.  
  The user passes in an index, and we check whether it is one of the available colors 
  for chairs.  if not, a default value is used.  
  */
  public void SetColor(int colorIndex)  {
    if(colorIndex == RED) {
      myColor = RED;
      myColorString = "Red";
    }
    else if(colorIndex == BLUE) {
      myColor = BLUE;
      myColorString = "Blue";
    }
    else if(colorIndex == GREEN)  {
      myColor = GREEN;
      myColorString = "Green";
    }
    else {
       System.out.print("Invalid color choice: your chair will be made GREEN.\n");
       myColor = GREEN;
       myColorString = "Green";
    }
  }
  
  /*Is this a class or instance method?*/
  public static int GetNumMade() {
    return numMade;
  }
  
  public int GetColor() {
    if(myColor == NOT_PAINTED) {
      System.out.print("This chair is not yet painted. \n");
    }
    return myColor;
  }
  
  public boolean IsPainted() {
    return (myColor != NOT_PAINTED);
  }
}
