Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
875 B
2
Indexable
Never

public class AL07 {

    public enum Network {
        FRIENDLY, UNFRIENDLY, UNKNOWN;
    }

    private DisjointSubsets disjointSubsets = new DisjointSubsets();

    public AL07() {
        // don't remove
    }

    public DisjointSubsets getDisjointSubsets() {
        return disjointSubsets;
    }

    public void talkedToEachOther(String name1, String name2) {
        getDisjointSubsets().union(name1, name2);
    }

    public void addPerson(String name) {
        getDisjointSubsets().addSubset(name);
    }

    public void friendly(String name) {
        getDisjointSubsets().union(name, Network.FRIENDLY.name());
    }

    public void unfriendly(String name) {
        getDisjointSubsets().union(name, Network.UNFRIENDLY.name());
    }

    public Network memberOfNetwork(String name) {
        return Network.valueOf(getDisjointSubsets().find(name));
    }

}