package org.josast.TLM;

public class BooleanTLM {

	protected boolean[] bool = new boolean[8];

	public BooleanTLM() {

	}

	public boolean getValue(int data) {
		return this.bool[data];
	}

	public boolean[] convertToBoolean(int in, int lengh) {

		String maxAmpStr = Integer.toBinaryString(in);
		char[] arr = maxAmpStr.toCharArray();
		boolean[] bool = new boolean[lengh];
		int j = 0;
		for (int i = arr.length - 1; i >= 0; i--) {
			if (arr[i] == '1') {
				bool[j++] = true;
			} else if (arr[i] == '0') {
				bool[j++] = false;
			}
		}

		return bool;
	}

	public String toString() {

		StringBuilder stringBuilder = new StringBuilder();
		for (int j = 0; j < 8; j++) {

			stringBuilder.append(bool[j] + ",");
		}

		return stringBuilder.toString();
	}

}
