package salesQuota1;

/**
 * A class to model a salesperson in an organization
 * 
 * @author myersjac
 *
 */
public class Salesperson {
	
	private String name;
	private Level level;
	
	/**
	 * inner enum to identify the level of the salesperson
	 * 
	 * Note the ordinal values will be
	 * 		0 for Undetermined
	 * 		1 for Junior
	 * 		2 for Experienced
	 * 		3 for Senior
	 * 
	 * @author myersjac
	 */
	public static enum Level {
		UNDETERMINED, JUNIOR, EXPERIENCED, SENIOR
	}

	/** 
	 * Constructor
	 * 
	 * @param name		the name of the salesperson
	 * @param level		the string representation of the Level enum
	 */
	public Salesperson(String name, String level) {
		this.name = name;
		setLevelEnum(level);
	}
	
	/**
	 * Sets the level enum for a Salesperson.  Invalid enum values
	 * will be set as "Undetermined"
	 * 
	 * @param level		the string representation of the level enum
	 */
	private void setLevelEnum (String level) {
		try {
			this.level = Level.valueOf(level);
		}
		catch (IllegalArgumentException e){
			this.level = Level.UNDETERMINED;
		}	
	}
	
	// Standard getters and setters
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Level getLevel() {
		return level;
	}

	public void setLevel(Level level) {
		this.level = level;
	}
	
	/**
	 * This getter will return the string value of the enum
	 * 
	 * @return		the name of the level enum
	 */
	public String getLevelString() {
		return level.name();
	}
	
	/**
	 * This getter will return the ordinal value of the enum
	 * 
	 * @return		the ordinal value (index) of the level enum
	 */
	public int getLevelInt() {
		return level.ordinal();
	}

	@Override
	public String toString() {
		return name + " (" + level + ")";
	}



	

}
