import java.util.*;

public class WordScrambleEx1 {
	public static void main(String[] args){
	String[] strArr = {"Change", "Love", "Hope", "View"};
		
	String answer = getAnswer(strArr); 
        String question = getScrambledWord(answer); 
        Scanner scan = new Scanner(System.in);
        char[] hint = new char[answer.length()];
        
        for(int i=0;i < hint.length;i++) { 
            hint[i] = '_'; 
        } 
      
        System.out.println("讌覓: "+question); 
        for(;;){
        	System.out.print("給: ");
        	
        	String strIn;
        	strIn = scan.nextLine(); 
        	
        	if (strIn.equalsIgnoreCase("q"))
        		System.exit(0);
        	
        	if (strIn.equalsIgnoreCase(answer)){
        		System.out.println("豢. 旧!!");
        		System.out.println();
        		break;
        	}
        	else{
        		System.out.println("旧 . れ ロ語:");
        		System.out.println("Hint:" + getHint(answer, hint));
        	}
        		
        		
        } //for
        
	} // main
	
	public static String getAnswer(String[] strArr){
		int rand = (int)(Math.random() * 10 % strArr.length);
		return strArr[rand];
	} //getAnswer
	
	public static String getScrambledWord(String str){	
		char[] chArr = str.toCharArray();
		char tmp;
		int rand;
		
		for(int i=0;i<str.length();i++){
			rand = (int)(Math.random() * 10 % str.length());
			tmp = chArr[i];
			chArr[i] = chArr[rand];
			chArr[rand] = tmp;
		}
		return new String(chArr);

	} //getScrambledWord
	
	public static String getHint(String answer, char[] hint){
		int count = 0;
		int rand;
		
		for(int i=0; i<hint.length; i++)
			if(hint[i] == '_') count++;
		
		if (count>2){
			for(int i=0;i<answer.length();i++){
				rand = (int)(Math.random() * 10 % answer.length());
				if(hint[rand] == '_'){
					hint[rand] = answer.toCharArray()[rand];
					break;
				}
			}
		}
		return new String(hint);		
	} //getHint
} //WordScrambleEx