// Arup Guha
// 4/24/2016
// Solution to 2015 AP CS A Free Response Question 2: Hidden Word Game

public class HiddenWord {

	// We store both the hidden word and its letter frequencies (note: a boolean array would also work.)
	private String word;
	private int[] freq;

	public HiddenWord(String myWord) {
		word = myWord;
		freq = new int[26];
		for (int i=0; i<myWord.length(); i++)
			freq[myWord.charAt(i)-'A']++;
	}

	public String getHint(String guess) {

		String res = "";

		// Buiild the result 1 character at a time.
		for (int i=0; i<guess.length(); i++) {

			// We got the letter!
			if (guess.charAt(i) == word.charAt(i))
				res = res + word.charAt(i);

			// This letter is in the word, but not in this spot.
			else if (freq[guess.charAt(i)-'A'] > 0)
				res = res + "+";

			// This letter is not in the word.
			else
				res = res + "*";
		}

		return res;
	}

	// Just run their game.
	public static void main(String[] args) {
		HiddenWord puzzle = new HiddenWord("HARPS");
		System.out.println(puzzle.getHint("AAAAA"));
		System.out.println(puzzle.getHint("HELLO"));
		System.out.println(puzzle.getHint("HEART"));
		System.out.println(puzzle.getHint("HARMS"));
		System.out.println(puzzle.getHint("HARPS"));
	}
}