public void moveHead(String direction) {
		try {
			switch (direction.charAt(0)) {
			case 'L':
				tapeHead--;
				break;
			case 'R':
				tapeHead++;
				break;
			case 'S':
				break;
			default:
				throw new IllegalArgumentException("Bad tape direction "
						+ direction);
			}
		} catch (IndexOutOfBoundsException e) {
			throw new IllegalArgumentException(
					"Tape direction is empty string!");
		}

		/**
		 * If the tape head is moved to an index out of the range of the buffer,
		 * the buffer needs to grow accordingly, filled with blanks where
		 * appropriate.
		 */

		if (tapeHead >= buffer.length()) {
			int bufferLength = buffer.length();
			buffer.setLength(tapeHead + 1);
			for (int k = bufferLength; k < buffer.length(); k++) {
				buffer.deleteCharAt(k);
				buffer.insert(k, BLANK);
			}
		} else if (tapeHead < 0) {
			int numToInsert = Math.abs(tapeHead);
			char[] toInsert = new char[numToInsert];
			for (int i = 0; i < numToInsert; i++) {
				toInsert[i] = BLANK;
			}
			buffer.insert(0, toInsert);
			tapeHead = 0;
		}
	}