package task4;

import java.lang.reflect.Array;
import java.util.Arrays;

public class AnagrammChecker {
    private String word0;
    private String word1;

    public AnagrammChecker(String word0, String word1){
        this.word0 = word0;
        this.word1 = word1;
    }



    public void isAnagram(){
        String sortedWord0 = sortString(word0);
        String sortedWord1 = sortString(word1);

        if (sortedWord1.equals(sortedWord0)) {
            System.out.println("Die Wörter sind Anagramme.");
        } else {
            System.out.println("Die Wörter sind keine Anagramme.");
        }
    }

    private String sortString(String string) {
        char tempArr[] = string.toCharArray();

        Arrays.sort(tempArr);

        return new String(tempArr);
    }
}
