Package com.poker.analyst.combination

Source Code of com.poker.analyst.combination.TwoPairs

package com.poker.analyst.combination;

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

import com.poker.analyst.combinations.auxil.CardRangeInComb;
import com.poker.analyst.combinations.auxil.CardValue;
import com.poker.analyst.element.Card;
import com.poker.analyst.element.CardFace;
import com.poker.analyst.element.Hand;

public class TwoPairs extends Combination {

    @Override
    public Integer getCombinationValue() {

        return 2;
    }
   
   
    @Override
  public List<CardValue> getCardValues(Hand hand) {
    List<CardValue> listCardValues = null;
    CardValue cardValue;
    Card plCard;
       
   
    CardFace cface = getMaxValue();
    for (int q = 0; q<2 ; q++){
      plCard = hand.getHandCards()[q];
      if (cface.equals(plCard.getFace())){
        if (listCardValues == null) listCardValues = new ArrayList<CardValue>();
        cardValue = new CardValue();
        cardValue.setCard(plCard);
        cardValue.setCardPosition(0);
        cardValue.setCardRange(CardRangeInComb.TOP);
        listCardValues.add(cardValue);
      }
    }
    cface = getMinValue();
    for (int q = 0; q<2 ; q++){
      plCard = hand.getHandCards()[q];
      if (cface.equals(plCard.getFace())){
        if (listCardValues == null) listCardValues = new ArrayList<CardValue>();
        cardValue = new CardValue();
        cardValue.setCard(plCard);
        cardValue.setCardPosition(1);
        cardValue.setCardRange(CardRangeInComb.LOW);
        listCardValues.add(cardValue);
      }
    }
    return listCardValues;
  }
   
    @Override
    public String toString() {
    String str = "TwoPairs :  [ ";
       
    for (Card card : this.getCombinationList())
      str += card + " ";
   
    str += "]";
        return str;
    }   
 
  @Override
  public CardFace getMinValue() {
    if (getCombinationList() != null && getCombinationList().size() != 0)
      return getCombinationList().get(getCombinationList().size() - 1).getFace();
    else
      return null;
  }

  @Override
  public CardFace getMaxValue() {
    if (getCombinationList() != null && getCombinationList().size() != 0)
      return getCombinationList().get(0).getFace();
    else
      return null;
  }

}
TOP

Related Classes of com.poker.analyst.combination.TwoPairs

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.