<commit_before>package hu.progtech.setcardgame.bl;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by marianna on 2016.04.10..
 */
public class SetOfCards {

    private List<Card> cardSet;

    public SetOfCards() {
        cardSet = new ArrayList<>();
    }

    public SetOfCards(List<Card> cardSet) {
        this.cardSet = cardSet;
    }

    public SetOfCards(Card c1, Card c2, Card c3) {
        cardSet = new ArrayList<>();
        cardSet.add(c1);
        cardSet.add(c2);
        cardSet.add(c3);

    }

    public void addCardtoSet(Card card) {
        if(cardSet.size()<3) {
            cardSet.add(card);
        }/*else {
            cardSet.clear();
            cardSet.add(card);
        }*/
    }

    private boolean isAllDiffrent(int a, int b, int c) {
        return (a != b && a != c && b != c)?true:false;
    }

    private boolean isAllSame(int a, int b, int c) {
        return (a == b && a == c && b == b)?true:false;
    }

    private boolean isNumberValid() {
        if(
                 isAllDiffrent(cardSet.get(0).getNumber(),cardSet.get(1).getNumber(),cardSet.get(2).getNumber())
                    ||
                    isAllSame(cardSet.get(0).getNumber(),cardSet.get(1).getNumber(),cardSet.get(2).getNumber())
                ) {
            return true;
        }
        return false;
    }

    private boolean isShapeValid() {
        if(
                isAllDiffrent(cardSet.get(0).getShape(),cardSet.get(1).getShape(),cardSet.get(2).getShape())
                        ||
                        isAllSame(cardSet.get(0).getShape(),cardSet.get(1).getShape(),cardSet.get(2).getShape())
                ) {
            return true;
        }
        return false;
    }

    private boolean isShadingValid() {
        if(
                isAllDiffrent(cardSet.get(0).getShading(),cardSet.get(1).getShading(),cardSet.get(2).getShading())
                        ||
                        isAllSame(cardSet.get(0).getShading(),cardSet.get(1).getShading(),cardSet.get(2).getShading())
                ) {
            return true;
        }
        return false;
    }

    private boolean isColorValid() {
        if(
                isAllDiffrent(cardSet.get(0).getColor(),cardSet.get(1).getColor(),cardSet.get(2).getColor())
                        ||
                        isAllSame(cardSet.get(0).getColor(),cardSet.get(1).getColor(),cardSet.get(2).getColor())
                ) {
            return true;
        }
        return false;
    }

    public boolean isSet() {
        if(cardSet.size()==3) {
            if(isNumberValid() && isShapeValid() && isShadingValid() && isColorValid()) {
                return true;
            }
        }
        return false;
    }

    public List<Card> getCardSet() {
        return cardSet;
    }

    public void setCardSet(List<Card> cardSet) {
        this.cardSet = cardSet;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        SetOfCards that = (SetOfCards) o;

        return cardSet != null ? cardSet.equals(that.cardSet) : that.cardSet == null;

    }

    @Override
    public int hashCode() {
        return cardSet != null ? cardSet.hashCode() : 0;
    }

    @Override
    public String toString() {
        return "SetOfCards{" +
                "cardSet=" + cardSet +
                '}';
    }

    public void removeFromSetOfCards(Card c) {
        cardSet.remove(c);
    }
}
<commit_msg>JavaDoc SetOfCards<commit_after>package hu.progtech.setcardgame.bl;

/**
 * Created by marianna on 2016.04.10..
 */

import java.util.ArrayList;
import java.util.List;

/**
 * SetOfCards class represents a Set made up by three Cards.
 */

public class SetOfCards {

    /**
     * A List containing the three Cards.
     */

    private List<Card> cardSet;

    /**
     * Initializes a newly created SetOfCards object.
     */

    public SetOfCards() {
        cardSet = new ArrayList<>();
    }

    /**
     * Constructs a new SetOfCards object by setting the value of the List of Cards.
     * @param cardSet A List containing the three Cards

     */

    public SetOfCards(List<Card> cardSet) {
        this.cardSet = cardSet;
    }

    /**
     * Constructs a new SetOfCards object by setting the value of the List of Cards with three Card objects.
     * @param c1 A Card object
     * @param c2 A Card object
     * @param c3 A Card object
     */

    public SetOfCards(Card c1, Card c2, Card c3) {
        cardSet = new ArrayList<>();
        cardSet.add(c1);
        cardSet.add(c2);
        cardSet.add(c3);

    }

    /**
     * Adds a Card object to the List of Cards if there is less than three Cards in it.
     * @param card A Card object
     */

    public void addCardtoSet(Card card) {
        if(cardSet.size()<3) {
            cardSet.add(card);
        }
    }

    /**
     * Compares three values of the same property of a Card.
     * @param a The first value
     * @param b The second value
     * @param c The third value
     * @return True if the three values are all different, false if not.
     */

    private boolean isAllDiffrent(int a, int b, int c) {
        return (a != b && a != c && b != c)?true:false;
    }

    /**
     * Compares three values of the same property of a Card.
     * @param a The first value
     * @param b The second value
     * @param c The third value
     * @return True if the three values are all the same, false if not.
     */

    private boolean isAllSame(int a, int b, int c) {
        return (a == b && a == c && b == b)?true:false;
    }

    /**
     * Returns true if the number properties of the three cards in the list are compatible to make a Set.
     * @return Returns true if the number properties of the three cards in the list are compatible to make a Set, false if not
     */

    private boolean isNumberValid() {
        if(
                 isAllDiffrent(cardSet.get(0).getNumber(),cardSet.get(1).getNumber(),cardSet.get(2).getNumber())
                    ||
                    isAllSame(cardSet.get(0).getNumber(),cardSet.get(1).getNumber(),cardSet.get(2).getNumber())
                ) {
            return true;
        }
        return false;
    }

    /**
     * Returns true if the shape properties of the three cards in the list are compatible to make a Set.
     * @return Returns true if the shape properties of the three cards in the list are compatible to make a Set, false if not
     */

    private boolean isShapeValid() {
        if(
                isAllDiffrent(cardSet.get(0).getShape(),cardSet.get(1).getShape(),cardSet.get(2).getShape())
                        ||
                        isAllSame(cardSet.get(0).getShape(),cardSet.get(1).getShape(),cardSet.get(2).getShape())
                ) {
            return true;
        }
        return false;
    }

    /**
     * Returns true if the shading properties of the three cards in the list are compatible to make a Set.
     * @return Returns true if the shading properties of the three cards in the list are compatible to make a Set, false if not
     */

    private boolean isShadingValid() {
        if(
                isAllDiffrent(cardSet.get(0).getShading(),cardSet.get(1).getShading(),cardSet.get(2).getShading())
                        ||
                        isAllSame(cardSet.get(0).getShading(),cardSet.get(1).getShading(),cardSet.get(2).getShading())
                ) {
            return true;
        }
        return false;
    }

    /**
     * Returns true if the color properties of the three cards in the list are compatible to make a Set.
     * @return Returns true if the color properties of the three cards in the list are compatible to make a Set, false if not
     */

    private boolean isColorValid() {
        if(
                isAllDiffrent(cardSet.get(0).getColor(),cardSet.get(1).getColor(),cardSet.get(2).getColor())
                        ||
                        isAllSame(cardSet.get(0).getColor(),cardSet.get(1).getColor(),cardSet.get(2).getColor())
                ) {
            return true;
        }
        return false;
    }

    /**
     * Returns true if the three Cards in the cardSet are compatible to form a Set and false if not.
     * @return Returns true if the three Cards in the cardSet are compatible to form a Set, false if not
     */

    public boolean isSet() {
        if(cardSet.size()==3) {
            if(isNumberValid() && isShapeValid() && isShadingValid() && isColorValid()) {
                return true;
            }
        }
        return false;
    }

    /**
     * Returns the List of Cards.
     * @return The List of Cards
     */

    public List<Card> getCardSet() {
        return cardSet;
    }

    /**
     * Sets the list of Cards.
     * @param cardSet The List of Cards
     */

    public void setCardSet(List<Card> cardSet) {
        this.cardSet = cardSet;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        SetOfCards that = (SetOfCards) o;

        return cardSet != null ? cardSet.equals(that.cardSet) : that.cardSet == null;

    }

    @Override
    public int hashCode() {
        return cardSet != null ? cardSet.hashCode() : 0;
    }

    @Override
    public String toString() {
        return "SetOfCards{" +
                "cardSet=" + cardSet +
                '}';
    }

    public void removeFromSetOfCards(Card c) {
        cardSet.remove(c);
    }
}

{'fraction_non_alphanumeric': 0.11761032472939217, 'fraction_numerical': 0.008846794338051623, 'mean_word_length': 1.8471111111111111, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7484276', 'n_tokens_mistral': 2936, 'n_tokens_neox': 2811, 'n_words': 782}